From 092c5a6a0300c1232c32ccf659f9b24aa3ed299b Mon Sep 17 00:00:00 2001 From: Artemy Date: Mon, 8 Aug 2022 17:38:09 +0300 Subject: [PATCH] refactor: remove unused returns --- src/interpreter.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index 877d4cb..ac9ace2 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -90,7 +90,7 @@ impl Interpreter { }, "let" => match value { Value::Object(value) => { - return self.define(value); + self.define(value); } _ => { self.error("Unsupported data type for the `let` argument, must be an object"); @@ -98,7 +98,7 @@ impl Interpreter { }, "assign" => match value { Value::Object(value) => { - return self.assign(value); + self.assign(value); } _ => { self.error("Unsupported data type for the `assign` argument, must be an object"); @@ -106,7 +106,7 @@ impl Interpreter { }, "var" => match value { Value::String(value) => { - return self.get_var(value); + self.get_var(value); } _ => { self.error("Unsupported data type for the `var` argument, must be a string"); @@ -283,7 +283,7 @@ impl Interpreter { "end".to_string() } - fn define(&mut self, vars: &Map) -> Value { + fn define(&mut self, vars: &Map) { for (name, value) in vars { if !self.var_exists(&name) { match value { @@ -297,24 +297,27 @@ impl Interpreter { } } else { self.error(&format!("The variable {} already exist, use assign", name)); - panic!() + panic!(); } } - Value::Null } - fn get_var(&mut self, var_name: &String) -> Value { + fn delete(&mut self, var_name: &String) {} + + fn get_var(&mut self, var_name: &String) { let var = self.vars.get(var_name); match var { - Some(var) => var.clone(), + Some(var) => { + var.clone(); + } None => { self.error(&format!("The variable {} does not exist", var_name)); - panic!() + panic!(); } } } - fn assign(&mut self, vars: &Map) -> Value { + fn assign(&mut self, vars: &Map) { for (name, value) in vars { if self.var_exists(&name) { match value { @@ -331,7 +334,6 @@ impl Interpreter { panic!(); } } - Value::Null } fn var_exists(&self, name: &String) -> bool {