Remove internal function.

This commit is contained in:
Stephen Chung 2020-03-27 16:46:19 +08:00
parent 796690f506
commit a541a4507f

View File

@ -880,24 +880,18 @@ impl<'e> Engine<'e> {
name: &str, name: &str,
args: A, args: A,
) -> Result<T, EvalAltResult> { ) -> Result<T, EvalAltResult> {
// Split out non-generic portion to avoid exploding code size let mut values = args.into_vec();
fn call_fn_internal( let mut arg_values: Vec<_> = values.iter_mut().map(Dynamic::as_mut).collect();
engine: &mut Engine,
name: &str,
mut values: Vec<Dynamic>,
) -> Result<Dynamic, EvalAltResult> {
let mut values: Vec<_> = values.iter_mut().map(Dynamic::as_mut).collect();
engine.call_fn_raw(name, &mut values, None, Position::none(), 0)
}
call_fn_internal(self, name, args.into_vec()).and_then(|b| { self.call_fn_raw(name, &mut arg_values, None, Position::none(), 0)
b.downcast().map(|b| *b).map_err(|a| { .and_then(|b| {
EvalAltResult::ErrorMismatchOutputType( b.downcast().map(|b| *b).map_err(|a| {
self.map_type_name((*a).type_name()).into(), EvalAltResult::ErrorMismatchOutputType(
Position::none(), self.map_type_name((*a).type_name()).into(),
) Position::none(),
)
})
}) })
})
} }
/// Optimize the `AST` with constants defined in an external Scope. /// Optimize the `AST` with constants defined in an external Scope.