From 55f740497b4498e594013cb8da11df9539d1d076 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 4 Dec 2015 23:26:08 +0100 Subject: [PATCH] Beautify get_tags() helper --- src/module/bm/commands.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/module/bm/commands.rs b/src/module/bm/commands.rs index 59f507f3..ee5630cb 100644 --- a/src/module/bm/commands.rs +++ b/src/module/bm/commands.rs @@ -153,21 +153,25 @@ fn get_filtered_files_from_backend<'a>(module: &'a Module, } fn get_tags<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> Vec { - debug!("Fetching tags from commandline"); - sub.value_of("tags").and_then(|tags| - Some(tags.split(",") - .into_iter() - .map(|s| s.to_string()) - .filter(|e| - if e.contains(" ") { - warn!("Tag contains spaces: '{}'", e); - false - } else { - true - }).collect() - ) - ).or(Some(vec![])).unwrap() + fn reject_if_with_spaces(e: &String) -> bool { + if e.contains(" ") { + warn!("Tag contains spaces: '{}'", e); + false + } else { + true + } + } + + debug!("Fetching tags from commandline"); + sub.value_of("tags").and_then(|tags| { + Some(tags.split(",") + .into_iter() + .map(|s| s.to_string()) + .filter(|e| reject_if_with_spaces(e)) + .collect() + ) + }).or(Some(vec![])).unwrap() } fn get_matcher<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> Option {