From fe0d46ecf3c91c1ded33cfaf089661eb9871ece7 Mon Sep 17 00:00:00 2001 From: numzero Date: Sat, 19 Apr 2025 11:00:07 +0300 Subject: [PATCH] Store function names --- src/run.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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),