Add FnPtr::call.

This commit is contained in:
Stephen Chung
2021-11-27 16:28:34 +08:00
parent d56585c877
commit 30bfdd841a
5 changed files with 111 additions and 6 deletions

View File

@@ -340,7 +340,7 @@ fn test_closures_external() -> Result<(), Box<EvalAltResult>> {
let fn_name = fn_ptr.fn_name().to_string();
let context = NativeCallContext::new(&engine, &fn_name, &lib);
// Closure 'f' captures: the engine, the AST, and the curried function pointer
// Closure 'f' captures: the engine, the AST, and the curried function pointer
let f = move |x: INT| fn_ptr.call_dynamic(&context, None, [x.into()]);
assert_eq!(f(42)?.into_string(), Ok("hello42".to_string()));