Fix no_std build.

This commit is contained in:
Stephen Chung 2021-03-24 10:38:56 +08:00
parent 3d0d5d1708
commit 3a1e93e324

View File

@ -7,7 +7,7 @@ use crate::stdlib::{
boxed::Box, boxed::Box,
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
fmt, fmt,
iter::empty, iter::{empty, once},
mem, mem,
string::String, string::String,
}; };
@ -326,22 +326,28 @@ impl FnPtr {
this_ptr: Option<&mut Dynamic>, this_ptr: Option<&mut Dynamic>,
mut arg_values: impl AsMut<[Dynamic]>, mut arg_values: impl AsMut<[Dynamic]>,
) -> RhaiResult { ) -> RhaiResult {
let arg_values = arg_values.as_mut(); let mut args_data;
let mut args_data = self let arg_values = if self.curry().is_empty() {
.curry() arg_values.as_mut()
.iter() } else {
.cloned() args_data = self
.chain(arg_values.iter_mut().map(mem::take)) .curry()
.collect::<Vec<_>>(); .iter()
.cloned()
.chain(arg_values.as_mut().iter_mut().map(mem::take))
.collect::<StaticVec<_>>();
let mut args = args_data.iter_mut().collect::<Vec<_>>(); args_data.as_mut()
};
let is_method = this_ptr.is_some(); let is_method = this_ptr.is_some();
if let Some(obj) = this_ptr { let mut args: StaticVec<_> = if let Some(obj) = this_ptr {
args.insert(0, obj); once(obj).chain(arg_values.iter_mut()).collect()
} } else {
arg_values.iter_mut().collect()
};
ctx.call_fn_dynamic_raw(self.fn_name(), is_method, args.as_mut()) ctx.call_fn_dynamic_raw(self.fn_name(), is_method, args.as_mut())
} }