Rename AnonymousFn to Func

This commit is contained in:
Stephen Chung
2020-04-09 10:38:33 +08:00
parent 518725e119
commit 34ef2d6e00
4 changed files with 61 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
#![cfg(not(feature = "no_function"))]
use rhai::{AnonymousFn, Engine, EvalAltResult, ParseErrorType, Scope, INT};
use rhai::{Engine, EvalAltResult, Func, ParseErrorType, Scope, INT};
#[test]
fn test_fn() -> Result<(), EvalAltResult> {
@@ -62,7 +62,10 @@ fn test_call_fn() -> Result<(), EvalAltResult> {
#[test]
fn test_anonymous_fn() -> Result<(), EvalAltResult> {
let calc_func = AnonymousFn::<(INT, INT, INT), INT>::create_from_script(
let calc_func: Box<dyn Fn(INT, INT, INT) -> Result<INT, EvalAltResult>> =
Engine::new().create_from_script("fn calc() { 42 }", "calc")?;
let calc_func = Func::<(INT, INT, INT), INT>::create_from_script(
Engine::new(),
"fn calc(x, y, z) { (x + y) * z }",
"calc",