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/mod.rs | |
| parent | 9950627789358b4d46c7fd8ba20d1428aee7bf01 (diff) | |
Eco string 🌱
Diffstat (limited to 'src/eval/mod.rs')
| -rw-r--r-- | src/eval/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 4992f70c..dc4ab7ee 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -17,6 +17,7 @@ use std::rc::Rc; use crate::cache::Cache; use crate::diag::{Diag, DiagSet, Pass}; +use crate::eco::EcoString; use crate::geom::{Angle, Fractional, Length, Relative}; use crate::loading::{FileHash, Loader}; use crate::parse::parse; @@ -528,7 +529,7 @@ impl Eval for ClosureExpr { visitor.finish() }; - let name = self.name.as_ref().map(|id| id.to_string()); + let name = self.name.as_ref().map(|name| name.string.clone()); Value::Func(FuncValue::new(name, move |ctx, args| { // Don't leak the scopes from the call site. Instead, we use the // scope of captured variables we collected earlier. @@ -555,7 +556,7 @@ impl Eval for WithExpr { let callee = self.callee.eval(ctx); if let Some(func) = ctx.cast::<FuncValue>(callee, self.callee.span()) { let applied = self.args.eval(ctx); - let name = func.name().map(|s| s.to_string()); + let name = func.name().cloned(); Value::Func(FuncValue::new(name, move |ctx, args| { // Remove named arguments that were overridden. let kept: Vec<_> = applied @@ -698,7 +699,7 @@ impl Eval for ImportExpr { fn eval(&self, ctx: &mut EvalContext) -> Self::Output { let path = self.path.eval(ctx); - if let Some(path) = ctx.cast::<String>(path, self.path.span()) { + if let Some(path) = ctx.cast::<EcoString>(path, self.path.span()) { if let Some(hash) = ctx.import(&path, self.path.span()) { let mut module = &ctx.modules[&hash]; match &self.imports { @@ -734,7 +735,7 @@ impl Eval for IncludeExpr { fn eval(&self, ctx: &mut EvalContext) -> Self::Output { let path = self.path.eval(ctx); - if let Some(path) = ctx.cast::<String>(path, self.path.span()) { + if let Some(path) = ctx.cast::<EcoString>(path, self.path.span()) { if let Some(hash) = ctx.import(&path, self.path.span()) { return Value::Template(ctx.modules[&hash].template.clone()); } |
