Add FnNamespace for module functions.
This commit is contained in:
@@ -267,7 +267,7 @@ fn test_closures_external() -> Result<(), Box<EvalAltResult>> {
|
||||
let fn_ptr = engine.eval_ast::<FnPtr>(&ast)?;
|
||||
|
||||
// Get rid of the script, retaining only functions
|
||||
ast.retain_functions(|_, _, _| true);
|
||||
ast.retain_functions(|_, _, _, _| true);
|
||||
|
||||
// Closure 'f' captures: the engine, the AST, and the curried function pointer
|
||||
let f = move |x: INT| fn_ptr.call_dynamic((&engine, &[ast.as_ref()]).into(), None, [x.into()]);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#![cfg(not(feature = "no_module"))]
|
||||
use rhai::{
|
||||
module_resolvers::StaticModuleResolver, Dynamic, Engine, EvalAltResult, ImmutableString,
|
||||
Module, ParseError, ParseErrorType, Scope, INT,
|
||||
module_resolvers::StaticModuleResolver, Dynamic, Engine, EvalAltResult, FnNamespace,
|
||||
ImmutableString, Module, ParseError, ParseErrorType, Scope, INT,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -23,7 +23,8 @@ fn test_module_sub_module() -> Result<(), Box<EvalAltResult>> {
|
||||
sub_module2.set_var("answer", 41 as INT);
|
||||
|
||||
let hash_inc = sub_module2.set_fn_1("inc", |x: INT| Ok(x + 1));
|
||||
sub_module2.set_fn_1_mut("super_inc", |x: &mut INT| Ok(*x + 1));
|
||||
let hash_super_inc = sub_module2.set_fn_1_mut("super_inc", |x: &mut INT| Ok(*x + 1));
|
||||
sub_module2.set_fn_namespace(hash_super_inc, FnNamespace::Global);
|
||||
|
||||
sub_module.set_sub_module("universe", sub_module2);
|
||||
module.set_sub_module("life", sub_module);
|
||||
|
Reference in New Issue
Block a user