Simplify implementation

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-05 01:10:46 +01:00
parent 8a4bc0eba4
commit 751ce5af1a

View file

@ -263,18 +263,14 @@ fn translate_destination(raw: &str) -> Result<LogDestination> {
fn translate_destinations(raw: &Vec<Value>) -> Result<Vec<LogDestination>> { fn translate_destinations(raw: &Vec<Value>) -> Result<Vec<LogDestination>> {
raw.iter() raw.iter()
.fold(Ok(vec![]), |acc, val| { .map(|val| {
acc.and_then(|mut v| { val.as_str()
let dest = val.as_str() .ok_or_else(|| "Type error at 'imag.logging.modules.<mod>.destinations', expected Array<String>")
.ok_or_else(|| { .map_err(err_msg)
let msg = "Type error at 'imag.logging.modules.<mod>.destinations', expected Array<String>"; .map_err(Error::from)
Error::from(err_msg(msg)) .and_then(|s| translate_destination(s))
})
.and_then(translate_destination)?;
v.push(dest);
Ok(v)
})
}) })
.collect()
} }
fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Value>) fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Value>)