From bec8aedc2287a1d588c3897f69b51085ba74e336 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 8 Jan 2018 05:21:04 -0800 Subject: [PATCH] Simplify some code --- src/schala_lang/mod.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index 2061a4f..5934b9d 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -36,7 +36,6 @@ impl ProgrammingLanguageInterface for Schala { if options.debug_tokens { let token_string = tokens.iter().map(|t| format!("{:?}<{}>", t.token_type, t.offset)).join(", "); output.add_artifact(TraceArtifact::new("tokens", format!("{:?}", token_string))); - } { @@ -80,16 +79,9 @@ impl ProgrammingLanguageInterface for Schala { } } - let evaluation_output = self.state.evaluate(ast); - let mut acc = String::new(); - let mut iter = evaluation_output.iter().peekable(); - while let Some(s) = iter.next() { - acc.push_str(&s); - if let Some(_) = iter.peek() { - acc.push_str("\n"); - } - } - output.add_output(acc); + let evaluation_outputs = self.state.evaluate(ast); + let text_output: String = evaluation_outputs.into_iter().intersperse(format!("\n")).collect(); + output.add_output(text_output); return output; } }