From 742975466562fd7a76ddf1c16db53cfc510dbf0c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 Mar 2018 22:57:07 +0100 Subject: [PATCH] Rewrite edit_in_tmpfile() for new Runtime::editor() signature --- lib/entry/libimagentryedit/src/edit.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/entry/libimagentryedit/src/edit.rs b/lib/entry/libimagentryedit/src/edit.rs index 6802eaa3..b2d45383 100644 --- a/lib/entry/libimagentryedit/src/edit.rs +++ b/lib/entry/libimagentryedit/src/edit.rs @@ -72,18 +72,19 @@ impl EditHeader for Entry { pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { use libimagutil::edit::edit_in_tmpfile_with_command; - rt.editor() - .ok_or(EE::from_kind(EditErrorKind::NoEditor)) - .and_then(|editor| { - edit_in_tmpfile_with_command(editor, s) - .chain_err(|| EditErrorKind::IOError) - .and_then(|worked| { - if !worked { - Err(EditErrorKind::ProcessExitFailure.into()) - } else { - Ok(()) - } - }) + let editor = rt + .editor() + .chain_err(|| EditErrorKind::NoEditor)? + .ok_or_else(|| EE::from_kind(EditErrorKind::NoEditor))?; + + edit_in_tmpfile_with_command(editor, s) + .chain_err(|| EditErrorKind::IOError) + .and_then(|worked| { + if !worked { + Err(EditErrorKind::ProcessExitFailure.into()) + } else { + Ok(()) + } }) }