From e7c53d84ca9ad778d0b179e12567557990906121 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 3 Jun 2017 14:53:52 +0200 Subject: [PATCH] Minify map/filter_map --- libimagrt/src/configuration.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 38de0789..fe1c1614 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -245,7 +245,7 @@ fn fetch_config(rtp: &PathBuf) -> Result { ].iter() .flatten() .filter(|path| path.exists() && path.is_file()) - .map(|path| { + .filter_map(|path| if path.exists() && path.is_file() { debug!("Reading {:?}", path); let content = { let mut s = String::new(); @@ -266,8 +266,9 @@ fn fetch_config(rtp: &PathBuf) -> Result { .map_err(|e| REK::Instantiate.into_error_with_cause(e)); Some(toml) + } else { + None }) - .filter_map(|x| x) .filter(|loaded| loaded.is_ok()) .map(|inner| Value::Table(inner.unwrap())) .nth(0)