Refactoring: Use function chaining rather than matching
This commit is contained in:
parent
4bb0d0f073
commit
e7d5e9ebc2
1 changed files with 6 additions and 7 deletions
|
@ -46,13 +46,12 @@ impl Note for Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_name(&self) -> Result<String> {
|
fn get_name(&self) -> Result<String> {
|
||||||
match self.get_header().read("note.name") {
|
self.get_header()
|
||||||
Ok(Some(&Value::String(ref s))) => Ok(s.clone()),
|
.read("note.name")
|
||||||
Ok(_) => {
|
.chain_err(|| NEK::StoreReadError)?
|
||||||
Err(NE::from_kind(NEK::HeaderTypeError)).chain_err(|| NEK::StoreReadError)
|
.and_then(Value::as_str)
|
||||||
},
|
.map(String::from)
|
||||||
Err(e) => Err(e).chain_err(|| NEK::StoreReadError)
|
.ok_or(NE::from_kind(NEK::HeaderTypeError))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_text(&mut self, n: String) {
|
fn set_text(&mut self, n: String) {
|
||||||
|
|
Loading…
Reference in a new issue