Refactor: Use function chaining instead of matching
This commit is contained in:
parent
d5ce99b170
commit
4bb0d0f073
1 changed files with 4 additions and 5 deletions
|
@ -36,11 +36,10 @@ pub trait Log : DiaryEntry {
|
|||
impl Log for Entry {
|
||||
fn is_log(&self) -> Result<bool> {
|
||||
let location = "log.is_log";
|
||||
match self.get_header().read(location)? {
|
||||
Some(&Value::Boolean(b)) => Ok(b),
|
||||
Some(_) => Err(LE::from_kind(LEK::HeaderTypeError("boolean", location))),
|
||||
None => Ok(false)
|
||||
}
|
||||
self.get_header()
|
||||
.read(location)?
|
||||
.ok_or(LE::from_kind(LEK::HeaderTypeError("boolean", location)))
|
||||
.map(|v| v.as_bool().unwrap_or(false))
|
||||
}
|
||||
|
||||
fn make_log_entry(&mut self) -> Result<()> {
|
||||
|
|
Loading…
Reference in a new issue