From 55c2aa2749d90726fe5d8c73b59b173250ad410d Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Thu, 16 Jul 2020 21:15:24 +0800 Subject: [PATCH] refactor load_paths --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index de9f3ac..ce5249a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,11 +178,9 @@ fn main() -> std::io::Result<()> { ) .get_matches(); - let load_paths = if let Some(load_paths) = matches.values_of("LOAD_PATH") { - load_paths.map(|p| Path::new(p)).collect() - } else { - Vec::new() - }; + let load_paths = matches + .values_of("LOAD_PATH") + .map_or_else(Vec::new, |vals| vals.map(Path::new).collect()); let options = &Options::default() .load_paths(&load_paths)