From db781ed00fb112c756453c79ac6b0d3cf831cc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 2 Jan 2023 21:44:02 +0100 Subject: [PATCH] HAPPY CLIPPY IS HAPPY!!!! --- src/interpreter/functions.rs | 12 ++++++------ src/interpreter/interpretable.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/interpreter/functions.rs b/src/interpreter/functions.rs index 8335283..d13d15a 100644 --- a/src/interpreter/functions.rs +++ b/src/interpreter/functions.rs @@ -22,13 +22,13 @@ pub(crate) struct Function { impl Function { pub(crate) fn new( name: Option<&Token>, - params: &Vec, - body: &Vec, + params: &[Token], + body: &[ast::StmtNode], ) -> Rc> { let fun = Self { - name: name.map(|t| t.clone()), - params: params.clone(), - body: body.clone(), + name: name.cloned(), + params: params.to_owned(), + body: body.to_owned(), }; Rc::new(RefCell::new(fun)) } @@ -48,7 +48,7 @@ impl Callable for Function { let param_env = Environment::create_child(environment); for (arg, value) in izip!(self.params.iter(), arguments.into_iter()) { // FIXME: duplicate parameter names should be detected in the parser - param_env.borrow_mut().define(&arg, Some(value))?; + param_env.borrow_mut().define(arg, Some(value))?; } let child = Environment::create_child(¶m_env); diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index 57909ca..7844883 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -157,8 +157,8 @@ impl ast::StmtNode { &self, environment: &EnvironmentRef, name: &Token, - params: &Vec, - body: &Vec, + params: &[Token], + body: &[ast::StmtNode], ) -> InterpreterResult { let fun = Function::new(Some(name), params, body); environment