diff --git a/src/engine.rs b/src/engine.rs index 7b29129c..82484e70 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -890,7 +890,7 @@ impl Engine { match rhs { // xxx.fn_name(arg_expr_list) Expr::FnCall(x) if x.1.is_none() => { - let ((name, pos), modules, hash, args, def_val) = x.as_ref(); + let ((name, pos), _, hash, _, def_val) = x.as_ref(); let mut args: Vec<_> = once(obj) .chain( @@ -1394,7 +1394,7 @@ impl Engine { let mut arg_values = args_expr .iter() .map(|expr| self.eval_expr(scope, state, expr, level)) - .collect::, _>>()?; + .collect::, _>>()?; let mut args: Vec<_> = arg_values.iter_mut().collect(); @@ -1442,7 +1442,7 @@ impl Engine { let mut arg_values = args_expr .iter() .map(|expr| self.eval_expr(scope, state, expr, level)) - .collect::, _>>()?; + .collect::, _>>()?; let mut args: Vec<_> = arg_values.iter_mut().collect(); diff --git a/src/fn_call.rs b/src/fn_call.rs index c64ba035..e1da767b 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -3,14 +3,14 @@ #![allow(non_snake_case)] use crate::any::{Dynamic, Variant}; -use crate::stdlib::vec::Vec; +use crate::utils::StaticVec; /// Trait that represents arguments to a function call. /// Any data type that can be converted into a `Vec` can be used /// as arguments to a function call. pub trait FuncArgs { /// Convert to a `Vec` of the function call arguments. - fn into_vec(self) -> Vec; + fn into_vec(self) -> StaticVec; } /// Macro to implement `FuncArgs` for tuples of standard types (each can be @@ -19,11 +19,11 @@ macro_rules! impl_args { ($($p:ident),*) => { impl<$($p: Variant + Clone),*> FuncArgs for ($($p,)*) { - fn into_vec(self) -> Vec { + fn into_vec(self) -> StaticVec { let ($($p,)*) = self; #[allow(unused_mut)] - let mut v = Vec::new(); + let mut v = StaticVec::new(); $(v.push($p.into_dynamic());)* v diff --git a/src/utils.rs b/src/utils.rs index 2d0ae237..dba06db7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,7 +9,7 @@ use crate::stdlib::{ }; #[cfg(not(feature = "no_std"))] -use crate::stdlib::collections::hash_map::DefaultHasher; +use crate::stdlib::{collections::hash_map::DefaultHasher, iter::FromIterator}; #[cfg(feature = "no_std")] use ahash::AHasher; @@ -48,7 +48,7 @@ pub fn calc_fn_spec<'a>( /// This is essentially a knock-off of the [`staticvec`](https://crates.io/crates/staticvec) crate. /// This simplified implementation here is to avoid pulling in another crate. #[derive(Clone, Hash, Default)] -pub struct StaticVec { +pub struct StaticVec { /// Total number of values held. len: usize, /// Static storage. 4 slots should be enough for most cases - i.e. four levels of indirection. @@ -57,7 +57,19 @@ pub struct StaticVec { more: Vec, } -impl StaticVec { +impl FromIterator for StaticVec { + fn from_iter>(iter: X) -> Self { + let mut vec = StaticVec::new(); + + for x in iter { + vec.push(x); + } + + vec + } +} + +impl StaticVec { /// Create a new `StaticVec`. pub fn new() -> Self { Default::default()