From ec3b41809d80d445c30de71adfb03c61a066e2cc Mon Sep 17 00:00:00 2001 From: numzero Date: Fri, 11 Apr 2025 20:36:28 +0300 Subject: [PATCH] privatise --- src/run.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/run.rs b/src/run.rs index 9403afb..550bac5 100644 --- a/src/run.rs +++ b/src/run.rs @@ -32,8 +32,8 @@ impl Debug for Function { #[derive(Debug, Clone, Default)] pub struct Scope { - pub variables: HashMap, - pub functions: HashMap, + variables: HashMap, + functions: HashMap, } impl Scope { @@ -48,6 +48,11 @@ impl Scope { self.variables.remove(&name); } } + + pub fn add_fn(&mut self, name: &'static str, f: impl Fn(Vec) -> Value + 'static) { + self.functions + .insert(name.into(), Function::new(name.into(), f)); + } } pub trait Eval {