Store function names
This commit is contained in:
parent
0b5e9a5f44
commit
fe0d46ecf3
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
|
||||
#[derive(Clone)]
|
||||
struct Function {
|
||||
name: &'static str,
|
||||
name: String,
|
||||
inner: Rc<dyn Fn(&mut Scope, Vec<Value>) -> Value>,
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ impl Debug for Function {
|
|||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Scope {
|
||||
variables: HashMap<String, ValueInner>,
|
||||
functions: HashMap<&'static str, Function>,
|
||||
functions: HashMap<String, Function>,
|
||||
}
|
||||
|
||||
impl Scope {
|
||||
|
|
@ -43,11 +43,12 @@ impl Scope {
|
|||
|
||||
pub fn add_fn(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
name: impl Into<String>,
|
||||
f: impl Fn(&mut Scope, Vec<Value>) -> Value + 'static,
|
||||
) {
|
||||
let name = name.into();
|
||||
self.functions.insert(
|
||||
name,
|
||||
name.clone(),
|
||||
Function {
|
||||
name,
|
||||
inner: Rc::new(f),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user