From bbad841a603de9b6a363841967bf932c03102011 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 28 May 2016 21:27:55 +0200 Subject: [PATCH] Rewrite edit_entry() to use Store::get() --- imag-notes/src/main.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/imag-notes/src/main.rs b/imag-notes/src/main.rs index 4dcaac34..c73297d9 100644 --- a/imag-notes/src/main.rs +++ b/imag-notes/src/main.rs @@ -69,14 +69,19 @@ fn edit(rt: &Runtime) { } fn edit_entry(rt: &Runtime, name: String) -> bool { - let note = Note::retrieve(rt.store(), name); - if note.is_err() { - trace_error(¬e.unwrap_err()); - warn!("Cannot edit nonexistent Note"); - return false - } + let mut note = match Note::get(rt.store(), name) { + Ok(Some(note)) => note, + Ok(None) => { + warn!("Cannot edit nonexistent Note"); + return false + }, + Err(e) => { + trace_error(&e); + warn!("Cannot edit nonexistent Note"); + return false + }, + }; - let mut note = note.unwrap(); if let Err(e) = note.edit_content(rt) { trace_error(&e); warn!("Editing failed");