From 3294a77346857c2e011e7fd3429fa19c8945e7a4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Jan 2018 23:09:30 +0100 Subject: [PATCH] Refactoring: Use function chaining rather than matching --- lib/entry/libimagentryannotation/src/annotateable.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/entry/libimagentryannotation/src/annotateable.rs b/lib/entry/libimagentryannotation/src/annotateable.rs index ffd40879..aa027720 100644 --- a/lib/entry/libimagentryannotation/src/annotateable.rs +++ b/lib/entry/libimagentryannotation/src/annotateable.rs @@ -97,13 +97,9 @@ impl Annotateable for Entry { fn is_annotation(&self) -> Result { 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)) } }