Refactor: Use function chaining instead of matching

This commit is contained in:
Matthias Beyer 2018-01-04 23:09:06 +01:00
parent d5ce99b170
commit 4bb0d0f073

View file

@ -36,11 +36,10 @@ pub trait Log : DiaryEntry {
impl Log for Entry { impl Log for Entry {
fn is_log(&self) -> Result<bool> { fn is_log(&self) -> Result<bool> {
let location = "log.is_log"; let location = "log.is_log";
match self.get_header().read(location)? { self.get_header()
Some(&Value::Boolean(b)) => Ok(b), .read(location)?
Some(_) => Err(LE::from_kind(LEK::HeaderTypeError("boolean", location))), .ok_or(LE::from_kind(LEK::HeaderTypeError("boolean", location)))
None => Ok(false) .map(|v| v.as_bool().unwrap_or(false))
}
} }
fn make_log_entry(&mut self) -> Result<()> { fn make_log_entry(&mut self) -> Result<()> {