diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-10 13:07:39 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-10 13:07:39 +0200 |
| commit | 36b3067c19c8743032a44f888ee48702b88d135b (patch) | |
| tree | 89893f4501109b35bb6498b93bda4f3cc82dba40 /src/eval/scope.rs | |
| parent | 9950627789358b4d46c7fd8ba20d1428aee7bf01 (diff) | |
Eco string 🌱
Diffstat (limited to 'src/eval/scope.rs')
| -rw-r--r-- | src/eval/scope.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs index 3f7c4c62..05bbeda2 100644 --- a/src/eval/scope.rs +++ b/src/eval/scope.rs @@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Display, Formatter}; use std::iter; use std::rc::Rc; -use super::{AnyValue, EvalContext, FuncArgs, FuncValue, Type, Value}; +use super::{AnyValue, EcoString, EvalContext, FuncArgs, FuncValue, Type, Value}; /// A slot where a variable is stored. pub type Slot = Rc<RefCell<Value>>; @@ -39,17 +39,17 @@ impl<'a> Scopes<'a> { } /// Define a constant variable with a value in the active scope. - pub fn def_const(&mut self, var: impl Into<String>, value: impl Into<Value>) { + pub fn def_const(&mut self, var: impl Into<EcoString>, value: impl Into<Value>) { self.top.def_const(var, value); } /// Define a mutable variable with a value in the active scope. - pub fn def_mut(&mut self, var: impl Into<String>, value: impl Into<Value>) { + pub fn def_mut(&mut self, var: impl Into<EcoString>, value: impl Into<Value>) { self.top.def_mut(var, value); } /// Define a variable with a slot in the active scope. - pub fn def_slot(&mut self, var: impl Into<String>, slot: Slot) { + pub fn def_slot(&mut self, var: impl Into<EcoString>, slot: Slot) { self.top.def_slot(var, slot); } @@ -66,7 +66,7 @@ impl<'a> Scopes<'a> { #[derive(Default, Clone, PartialEq)] pub struct Scope { /// The mapping from names to slots. - values: HashMap<String, Slot>, + values: HashMap<EcoString, Slot>, } impl Scope { @@ -76,7 +76,7 @@ impl Scope { } /// Define a constant variable with a value. - pub fn def_const(&mut self, var: impl Into<String>, value: impl Into<Value>) { + pub fn def_const(&mut self, var: impl Into<EcoString>, value: impl Into<Value>) { let cell = RefCell::new(value.into()); // Make it impossible to write to this value again. @@ -87,7 +87,7 @@ impl Scope { } /// Define a constant function. - pub fn def_func<F>(&mut self, name: impl Into<String>, f: F) + pub fn def_func<F>(&mut self, name: impl Into<EcoString>, f: F) where F: Fn(&mut EvalContext, &mut FuncArgs) -> Value + 'static, { @@ -96,7 +96,7 @@ impl Scope { } /// Define a constant variable with a value of variant `Value::Any`. - pub fn def_any<T>(&mut self, var: impl Into<String>, any: T) + pub fn def_any<T>(&mut self, var: impl Into<EcoString>, any: T) where T: Type + Debug + Display + Clone + PartialEq + 'static, { @@ -104,12 +104,12 @@ impl Scope { } /// Define a mutable variable with a value. - pub fn def_mut(&mut self, var: impl Into<String>, value: impl Into<Value>) { + pub fn def_mut(&mut self, var: impl Into<EcoString>, value: impl Into<Value>) { self.values.insert(var.into(), Rc::new(RefCell::new(value.into()))); } /// Define a variable with a slot. - pub fn def_slot(&mut self, var: impl Into<String>, slot: Slot) { + pub fn def_slot(&mut self, var: impl Into<EcoString>, slot: Slot) { self.values.insert(var.into(), slot); } |
