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 {
|
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<()> {
|
||||||
|
|
Loading…
Reference in a new issue