Replace matching with function chaining
This commit is contained in:
parent
fa8ac03701
commit
4184a1e5d0
1 changed files with 10 additions and 14 deletions
|
@ -115,20 +115,16 @@ pub fn override_config(val: &mut Value, v: Vec<String>) -> Result<()> {
|
||||||
warn!("Could split at '=' - will be ignore override");
|
warn!("Could split at '=' - will be ignore override");
|
||||||
None
|
None
|
||||||
}))
|
}))
|
||||||
.map(|(k, v)| val
|
.map(|(k, v)| {
|
||||||
.read(&k[..])
|
let value = val
|
||||||
.chain_err(|| REK::ConfigTOMLParserError)
|
.read(&k)
|
||||||
.map(|toml| match toml {
|
.chain_err(|| REK::ConfigTOMLParserError)?
|
||||||
Some(value) => match into_value(value, v) {
|
.ok_or(RE::from_kind(REK::ConfigOverrideKeyNotAvailable))?;
|
||||||
Some(v) => {
|
|
||||||
info!("Successfully overridden: {} = {}", k, v);
|
into_value(value, v)
|
||||||
Ok(())
|
.map(|v| info!("Successfully overridden: {} = {}", k, v))
|
||||||
},
|
.ok_or_else(|| RE::from_kind(REK::ConfigOverrideTypeNotMatching))
|
||||||
None => Err(RE::from_kind(REK::ConfigOverrideTypeNotMatching)),
|
});
|
||||||
},
|
|
||||||
None => Err(RE::from_kind(REK::ConfigOverrideKeyNotAvailable)),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
for elem in iter {
|
for elem in iter {
|
||||||
let _ = try!(elem.chain_err(|| REK::ConfigOverrideError));
|
let _ = try!(elem.chain_err(|| REK::ConfigOverrideError));
|
||||||
|
|
Loading…
Reference in a new issue