Refactoring: Use function chaining rather than matching

This commit is contained in:
Matthias Beyer 2018-01-04 23:09:30 +01:00
parent 40490c10d6
commit 3294a77346

View file

@ -97,13 +97,9 @@ impl Annotateable for Entry {
fn is_annotation(&self) -> Result<bool> { fn is_annotation(&self) -> Result<bool> {
self.get_header() self.get_header()
.read("annotation.is_annotation") .read("annotation.is_annotation")?
.map_err(From::from) .map(|val| val.as_bool().unwrap_or(false))
.and_then(|res| match res { .ok_or(AE::from_kind(AEK::HeaderTypeError))
Some(&Value::Boolean(b)) => Ok(b),
None => Ok(false),
_ => Err(AE::from_kind(AEK::HeaderTypeError)),
})
} }
} }