From 36b3067c19c8743032a44f888ee48702b88d135b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 10 Jul 2021 13:07:39 +0200 Subject: =?UTF-8?q?Eco=20string=20=F0=9F=8C=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eval/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/eval/mod.rs') 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::(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::(path, self.path.span()) { + if let Some(path) = ctx.cast::(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::(path, self.path.span()) { + if let Some(path) = ctx.cast::(path, self.path.span()) { if let Some(hash) = ctx.import(&path, self.path.span()) { return Value::Template(ctx.modules[&hash].template.clone()); } -- cgit v1.2.3