From afb465d6df5d8978b70f0bf7e46c259b02cf4962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 7 Jan 2023 14:14:24 +0100 Subject: [PATCH] Interpreter - Use Value.to_string() for print statements --- src/interpreter/interpretable.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index e9a5a31..7639379 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -172,14 +172,7 @@ impl StmtNode { /// Handle the `print` statement. fn on_print(&self, es: &mut InterpreterState, expr: &ExprNode) -> InterpreterResult { let value = expr.interpret(es)?.result(); - let output = match value { - Value::Nil => String::from("nil"), - Value::Boolean(true) => String::from("true"), - Value::Boolean(false) => String::from("false"), - Value::Number(n) => n.to_string(), - Value::String(s) => s, - Value::Callable(c) => c.borrow().to_string(), - }; + let output = value.to_string(); println!("{}", output); Ok(InterpreterFlowControl::default()) }