Simplify call_fn API, no need to pass &mut references.
This commit is contained in:
@@ -4,9 +4,15 @@ use rhai::{Engine, EvalAltResult};
|
||||
fn test_engine_call_fn() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
let ast = engine.compile("fn hello(x, y) { x.len() + y }")?;
|
||||
let ast = engine.compile(
|
||||
r"
|
||||
fn hello(x, y) {
|
||||
x.len() + y
|
||||
}
|
||||
",
|
||||
)?;
|
||||
|
||||
let result: i64 = engine.call_fn("hello", &ast, (&mut String::from("abc"), &mut 123_i64))?;
|
||||
let result: i64 = engine.call_fn("hello", &ast, (String::from("abc"), 123_i64))?;
|
||||
|
||||
assert_eq!(result, 126);
|
||||
|
||||
|
Reference in New Issue
Block a user