Refactoring: Use function chaining rather than matching
This commit is contained in:
parent
40490c10d6
commit
3294a77346
1 changed files with 3 additions and 7 deletions
|
@ -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)),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue