From b1d8fdb398ae5e7e1ae5defd0ddd048f56655a49 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 6 Oct 2016 16:50:31 -0700 Subject: [PATCH] Don't print double newline for --show --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f907654..9f11cb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,8 +52,12 @@ pub struct Recipe<'a> { impl<'a> Display for Recipe<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { try!(writeln!(f, "{}:", self.name)); - for command in self.commands.iter() { - try!(writeln!(f, " {}", command)); + for (i, command) in self.commands.iter().enumerate() { + if i + 1 < self.commands.len() { + try!(writeln!(f, " {}", command)); + } { + try!(write!(f, " {}", command)); + } } Ok(()) }