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> {
|
||||
self.get_header()
|
||||
.read("annotation.is_annotation")
|
||||
.map_err(From::from)
|
||||
.and_then(|res| match res {
|
||||
Some(&Value::Boolean(b)) => Ok(b),
|
||||
None => Ok(false),
|
||||
_ => Err(AE::from_kind(AEK::HeaderTypeError)),
|
||||
})
|
||||
.read("annotation.is_annotation")?
|
||||
.map(|val| val.as_bool().unwrap_or(false))
|
||||
.ok_or(AE::from_kind(AEK::HeaderTypeError))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue