diff --git a/src/run.rs b/src/run.rs index fa0e677..c70d51d 100644 --- a/src/run.rs +++ b/src/run.rs @@ -7,7 +7,7 @@ use crate::{ #[derive(Clone)] struct Function { - name: &'static str, + name: String, inner: Rc) -> Value>, } @@ -20,7 +20,7 @@ impl Debug for Function { #[derive(Debug, Clone, Default)] pub struct Scope { variables: HashMap, - functions: HashMap<&'static str, Function>, + functions: HashMap, } impl Scope { @@ -43,11 +43,12 @@ impl Scope { pub fn add_fn( &mut self, - name: &'static str, + name: impl Into, f: impl Fn(&mut Scope, Vec) -> Value + 'static, ) { + let name = name.into(); self.functions.insert( - name, + name.clone(), Function { name, inner: Rc::new(f),