diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f5a5706..ad7c33d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ Bug fixes * Self-contained `AST` now works properly with `Engine::call_fn`. +Deprecated API's +---------------- + +* `FnPtr::num_curried` is deprecated in favor of `FnPtr::curry().len()`. + Version 1.7.0 ============= diff --git a/src/api/deprecated.rs b/src/api/deprecated.rs index 6d9d5463..01f9331f 100644 --- a/src/api/deprecated.rs +++ b/src/api/deprecated.rs @@ -259,6 +259,19 @@ impl From for RhaiResultOf { } impl FnPtr { + /// Get the number of curried arguments. + /// + /// # Deprecated + /// + /// This method is deprecated. Use [`curry().len()`][`FnPtr::curry`] instead. + /// + /// This method will be removed in the next major version. + #[deprecated(since = "1.8.0", note = "use `curry().len()` instead")] + #[inline(always)] + #[must_use] + pub fn num_curried(&self) -> usize { + self.curry().len() + } /// Call the function pointer with curried arguments (if any). /// The function may be script-defined (not available under `no_function`) or native Rust. /// diff --git a/src/types/fn_ptr.rs b/src/types/fn_ptr.rs index 9d2d60cf..1e36141b 100644 --- a/src/types/fn_ptr.rs +++ b/src/types/fn_ptr.rs @@ -88,12 +88,6 @@ impl FnPtr { pub fn is_curried(&self) -> bool { !self.1.is_empty() } - /// Get the number of curried arguments. - #[inline(always)] - #[must_use] - pub fn num_curried(&self) -> usize { - self.1.len() - } /// Does the function pointer refer to an anonymous function? /// /// Not available under `no_function`. @@ -219,8 +213,8 @@ impl FnPtr { let mut arg_values = arg_values.as_mut(); let mut args_data; - if self.num_curried() > 0 { - args_data = StaticVec::with_capacity(self.num_curried() + arg_values.len()); + if self.is_curried() { + args_data = StaticVec::with_capacity(self.curry().len() + arg_values.len()); args_data.extend(self.curry().iter().cloned()); args_data.extend(arg_values.iter_mut().map(mem::take)); arg_values = args_data.as_mut();