diff --git a/src/module/mod.rs b/src/module/mod.rs index 05435d4d..2cc8d04b 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -253,6 +253,17 @@ impl fmt::Debug for Module { } } +#[cfg(not(feature = "no_function"))] +impl>> From for Module { + fn from(iter: T) -> Self { + let mut module = Self::new(); + iter.into_iter().for_each(|fn_def| { + module.set_script_fn(fn_def); + }); + module + } +} + impl> Add for &Module { type Output = Module; diff --git a/src/parser.rs b/src/parser.rs index 171d1113..7922bb23 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3884,7 +3884,7 @@ impl Engine { return Ok(AST::new( statements, #[cfg(not(feature = "no_function"))] - functions.into_iter().map(|(.., v)| v).collect(), + crate::Module::from(functions.into_iter().map(|(.., v)| v)), )); }