diff --git a/src/ast.rs b/src/ast.rs index 6c04c0de..0e819c5c 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -148,6 +148,23 @@ impl<'a> Into> for &'a ScriptFnDef { } } +#[cfg(not(feature = "no_function"))] +impl std::cmp::PartialOrd for ScriptFnMetadata<'_> { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +#[cfg(not(feature = "no_function"))] +impl std::cmp::Ord for ScriptFnMetadata<'_> { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + match self.name.cmp(other.name) { + std::cmp::Ordering::Equal => self.params.len().cmp(&other.params.len()), + cmp => cmp, + } + } +} + /// Compiled AST (abstract syntax tree) of a Rhai script. /// /// # Thread Safety diff --git a/src/module/mod.rs b/src/module/mod.rs index 278731fc..3dc8265e 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1456,7 +1456,7 @@ impl Module { .filter(|f| f.func.is_script()) .for_each(|f| { // Encapsulate AST environment - let mut func = crate::fn_native::shared_take_or_clone(f.func.get_fn_def().clone()); + let mut func = f.func.get_fn_def().as_ref().clone(); func.lib = Some(ast.shared_lib()); func.mods = func_mods.clone(); module.set_script_fn(func);