From d8a6e9ca9ae9ce92105b63c57d3a67088fc4cf7e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Nov 2018 12:48:34 +0100 Subject: [PATCH] Rewrite iteration without collecting inbetween Because why not? Signed-off-by: Matthias Beyer --- bin/domain/imag-contact/src/main.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs index dc862080..68f47a49 100644 --- a/bin/domain/imag-contact/src/main.rs +++ b/bin/domain/imag-contact/src/main.rs @@ -142,19 +142,15 @@ fn list(rt: &Runtime) { } } } else { - let rendered = iterator + let output = rt.stdout(); + let mut output = output.lock(); + iterator .map(|(i, dvcard)| build_data_object_for_handlebars(i, &dvcard)) .map(|data| list_format.render("format", &data).map_err(Error::from)) .trace_unwrap_exit(1) - .collect::>(); - // collect, so that we can have rendered all the things and printing is faster. - - let output = rt.stdout(); - let mut output = output.lock(); - - rendered.into_iter().for_each(|s| { - writeln!(output, "{}", s).to_exit_code().unwrap_or_exit() - }); + .for_each(|s| { + writeln!(output, "{}", s).to_exit_code().unwrap_or_exit() + }); } }