Beautify get_tags() helper

This commit is contained in:
Matthias Beyer 2015-12-04 23:26:08 +01:00
parent a005d4209b
commit 55f740497b

View file

@ -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<String> {
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<Regex> {