Allow mutating a module-qualified function's first argument if it is a variable.
This commit is contained in:
@@ -73,6 +73,10 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
module.set_fn_4("sum".to_string(), |x: INT, y: INT, z: INT, w: INT| {
|
||||
Ok(x + y + z + w)
|
||||
});
|
||||
module.set_fn_1_mut("double".to_string(), |x: &mut INT| {
|
||||
*x *= 2;
|
||||
Ok(())
|
||||
});
|
||||
|
||||
resolver.insert("hello", module);
|
||||
|
||||
@@ -90,6 +94,18 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
import "hello" as h;
|
||||
let x = 21;
|
||||
h::double(x);
|
||||
x
|
||||
"#
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
{
|
||||
engine.set_max_modules(5);
|
||||
|
Reference in New Issue
Block a user