diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-02 16:32:30 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-02 16:32:30 +0100 |
| commit | 88e50a55afff7b809d4b9d6cfaf93275bfe06f56 (patch) | |
| tree | fc4792e851316f97a8c9acdc7f332d9edc62e4f9 /src/eval/func.rs | |
| parent | d3ccd55d4bdb85343ae80574b6833fac2cf22181 (diff) | |
Pass arguments to call and construct directly by value
Diffstat (limited to 'src/eval/func.rs')
| -rw-r--r-- | src/eval/func.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/eval/func.rs b/src/eval/func.rs index ccd0932f..6d405ca4 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -45,15 +45,17 @@ impl Func { } /// Call the function in the context with the arguments. - pub fn call(&self, ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> { - match self.0.as_ref() { - Repr::Native(native) => (native.func)(ctx, args), - Repr::Closure(closure) => closure.call(ctx, args), + pub fn call(&self, ctx: &mut EvalContext, mut args: Args) -> TypResult<Value> { + let value = match self.0.as_ref() { + Repr::Native(native) => (native.func)(ctx, &mut args)?, + Repr::Closure(closure) => closure.call(ctx, &mut args)?, Repr::With(wrapped, applied) => { args.items.splice(.. 0, applied.items.iter().cloned()); - wrapped.call(ctx, args) + return wrapped.call(ctx, args); } - } + }; + args.finish()?; + Ok(value) } /// Apply the given arguments to the function. |
