From 6d0851de4448278f04585421a808d7c12cb934ce Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 12 Oct 2020 19:36:34 +0800 Subject: [PATCH] Reverse function call parameter change. --- src/fn_call.rs | 16 +++++----------- src/scope.rs | 6 ------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index 62f90c3b..1357e7fa 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -456,8 +456,6 @@ impl Engine { /// Perform an actual function call, native Rust or scripted, taking care of special functions. /// Position in `EvalAltResult` is `None` and must be set afterwards. /// - /// Capture `Scope` is consumed by this function. - /// /// ## WARNING /// /// Function call arguments may be _consumed_ when the function requires them to be passed by value. @@ -473,7 +471,7 @@ impl Engine { is_ref: bool, _is_method: bool, pub_only: bool, - _capture: Option<&mut Scope>, // `Scope` is consumed. + _capture: Option, def_val: &Option, _level: usize, ) -> Result<(Dynamic, bool), Box> { @@ -553,7 +551,7 @@ impl Engine { #[cfg(not(feature = "no_closure"))] if let Some(captured) = _capture { captured - .iter_mut() + .into_iter() .filter(|ScopeEntry { name, .. }| { func.externals.contains(name.as_ref()) }) @@ -563,11 +561,9 @@ impl Engine { }| { // Consume the scope values. match typ { - ScopeEntryType::Normal => { - scope.push(name.clone(), mem::take(value)) - } + ScopeEntryType::Normal => scope.push(name, value), ScopeEntryType::Constant => { - scope.push_constant(name.clone(), mem::take(value)) + scope.push_constant(name, value) } }; }, @@ -1013,13 +1009,11 @@ impl Engine { let mut arg_values: StaticVec<_>; let mut args: StaticVec<_>; let mut is_ref = false; - let mut capture_scope = if cfg!(not(feature = "no_closure")) && capture && !scope.is_empty() - { + let capture = if cfg!(not(feature = "no_closure")) && capture && !scope.is_empty() { Some(scope.clone_visible()) } else { None }; - let capture = capture_scope.as_mut(); if args_expr.is_empty() && curry.is_empty() { // No arguments diff --git a/src/scope.rs b/src/scope.rs index 43ebdc65..c1c78181 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -488,12 +488,6 @@ impl<'a> Scope<'a> { }| { (name.as_ref(), typ.is_constant(), value) }, ) } - - /// Get a mutable iterator to entries in the Scope. - #[inline(always)] - pub(crate) fn iter_mut(&mut self) -> impl Iterator> { - self.0.iter_mut() - } } impl<'a, K: Into>> iter::Extend<(K, EntryType, Dynamic)> for Scope<'a> {