diff --git a/lib/core/libimagrt/src/logger.rs b/lib/core/libimagrt/src/logger.rs index cf4f975e..e9526a35 100644 --- a/lib/core/libimagrt/src/logger.rs +++ b/lib/core/libimagrt/src/logger.rs @@ -263,18 +263,14 @@ fn translate_destination(raw: &str) -> Result { fn translate_destinations(raw: &Vec) -> Result> { raw.iter() - .fold(Ok(vec![]), |acc, val| { - acc.and_then(|mut v| { - let dest = val.as_str() - .ok_or_else(|| { - let msg = "Type error at 'imag.logging.modules..destinations', expected Array"; - Error::from(err_msg(msg)) - }) - .and_then(translate_destination)?; - v.push(dest); - Ok(v) - }) + .map(|val| { + val.as_str() + .ok_or_else(|| "Type error at 'imag.logging.modules..destinations', expected Array") + .map_err(err_msg) + .map_err(Error::from) + .and_then(|s| translate_destination(s)) }) + .collect() } fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Value>)