diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-06-06 21:13:59 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-06-06 22:06:16 +0200 |
| commit | fd417da04f7ca4b995de7f6510abafd3e9c31307 (patch) | |
| tree | 3675529c75ca7363701ac8ea306de2cc1d3cbcb3 /src/eval/scope.rs | |
| parent | 168bdf35bd773e67343c965cb473492cc5cae9e7 (diff) | |
Improve value casting infrastructure
Diffstat (limited to 'src/eval/scope.rs')
| -rw-r--r-- | src/eval/scope.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs index 83d1703e..bc62feb1 100644 --- a/src/eval/scope.rs +++ b/src/eval/scope.rs @@ -4,7 +4,7 @@ use std::hash::Hash; use ecow::{eco_format, EcoString}; -use super::{Library, Value}; +use super::{IntoValue, Library, Value}; use crate::diag::StrResult; /// A stack of scopes. @@ -95,7 +95,7 @@ impl Scope { /// Bind a value to a name. #[track_caller] - pub fn define(&mut self, name: impl Into<EcoString>, value: impl Into<Value>) { + pub fn define(&mut self, name: impl Into<EcoString>, value: impl IntoValue) { let name = name.into(); #[cfg(debug_assertions)] @@ -103,16 +103,13 @@ impl Scope { panic!("duplicate definition: {name}"); } - self.0.insert(name, Slot::new(value.into(), Kind::Normal)); + self.0.insert(name, Slot::new(value.into_value(), Kind::Normal)); } /// Define a captured, immutable binding. - pub fn define_captured( - &mut self, - var: impl Into<EcoString>, - value: impl Into<Value>, - ) { - self.0.insert(var.into(), Slot::new(value.into(), Kind::Captured)); + pub fn define_captured(&mut self, var: impl Into<EcoString>, value: impl IntoValue) { + self.0 + .insert(var.into(), Slot::new(value.into_value(), Kind::Captured)); } /// Try to access a variable immutably. |
