From 8e1768b4247629ae54e5b280c5e5a2d76211f211 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Nov 2018 11:52:31 +0100 Subject: [PATCH] Refactor code to be more idomatic Signed-off-by: Matthias Beyer --- bin/domain/imag-bookmark/src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/domain/imag-bookmark/src/main.rs b/bin/domain/imag-bookmark/src/main.rs index eae6fdfa..2d0e22ff 100644 --- a/bin/domain/imag-bookmark/src/main.rs +++ b/bin/domain/imag-bookmark/src/main.rs @@ -57,6 +57,7 @@ use libimagbookmark::link::Link as BookmarkLink; use libimagerror::trace::{MapErrTrace, trace_error}; use libimagerror::io::ToExitCode; use libimagerror::exit::ExitUnwrap; +use libimagutil::debug_result::DebugResult; mod ui; @@ -152,14 +153,16 @@ fn list(rt: &Runtime) { .report_touched(collection.get_location()) .map_err_trace_exit_unwrap(1); - let links = collection.links(rt.store()).map_err_trace_exit_unwrap(1); - debug!("Listing..."); - for (i, link) in links.enumerate() { - match link { + collection + .links(rt.store()) + .map_dbg_str("Listing...") + .map_err_trace_exit_unwrap(1) + .into_iter() + .enumerate() + .for_each(|(i, link)| match link { Ok(link) => writeln!(rt.stdout(), "{: >3}: {}", i, link).to_exit_code().unwrap_or_exit(), Err(e) => trace_error(&e) - } - }; + }); debug!("... ready with listing"); }