From a9135a80fb4f19a68288aaa31aaae98067a20f0b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Jan 2018 20:26:01 +0100 Subject: [PATCH] Replace matching with command chaining --- lib/etc/libimaginteraction/src/ui.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/etc/libimaginteraction/src/ui.rs b/lib/etc/libimaginteraction/src/ui.rs index 9c16a2a5..501f792e 100644 --- a/lib/etc/libimaginteraction/src/ui.rs +++ b/lib/etc/libimaginteraction/src/ui.rs @@ -70,14 +70,13 @@ pub fn get_id(matches: &ArgMatches) -> Result> { pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result> { use interactor::{pick_file, default_menu_cmd}; - match get_id(matches).chain_err(|| IEK::IdSelectingError) { - Ok(v) => Ok(v), - Err(_) => { + get_id(matches) + .chain_err(|| IEK::IdSelectingError) + .or_else(|_| { let path = store_path.clone(); - let p = pick_file(default_menu_cmd, path).chain_err(|| IEK::IdSelectingError)?; - let id = StoreId::new_baseless(p).chain_err(|| IEK::StoreIdParsingError)?; + let p = pick_file(default_menu_cmd, path).chain_err(|| IEK::IdSelectingError)?; + let id = StoreId::new_baseless(p).chain_err(|| IEK::StoreIdParsingError)?; Ok(vec![id]) - }, - } + }) }