Simplify implementation of has_tags()

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-06-26 20:21:09 +02:00
parent 08ba6c68a6
commit 51dad94cc9

View file

@ -111,12 +111,7 @@ impl Tagable for Value {
}
fn has_tags(&self, tags: &[Tag]) -> Result<bool> {
let mut result = true;
for tag in tags {
result = result && self.has_tag(tag)?;
}
Ok(result)
tags.iter().map(|t| self.has_tag(t)).fold(Ok(true), |a, e| a.and_then(|b| Ok(b && e?)))
}
}