从 0.12 开始,config 的API发生重大改变。
以前版本
pub fn from_env() -> Result<Self, config::ConfigError> {
let mut cfg = config::Config::new();
cfg.merge(config::Environment::new())?;
cfg.try_into()
}
新版本
pub fn from_env() -> Result<Self, config::ConfigError> {
config::Config::builder()
.add_source(config::Environment::default())
.build()?
.try_deserialize()
}