diff --git a/README.md b/README.md index c78534a0..a379b829 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ let ast = Engine::compile("fn hello(x, y) { x.len() + y }")?; // Evaluate the function in the AST, passing arguments into the script as a tuple // (beware, arguments must be of the correct types because Rhai does not have built-in type conversions) -let result: i64 = engine.call_fn("hello", ast, (&mut String::from("abc"), &mut 123_i64))?; +let result: i64 = engine.call_fn("hello", &ast, (&mut String::from("abc"), &mut 123_i64))?; ``` # Values and types diff --git a/src/api.rs b/src/api.rs index b27378f2..d38dad9a 100644 --- a/src/api.rs +++ b/src/api.rs @@ -9,7 +9,7 @@ use crate::scope::Scope; use std::any::TypeId; use std::sync::Arc; -impl<'a> Engine<'a> { +impl<'e> Engine<'e> { pub(crate) fn register_fn_raw( &mut self, fn_name: &str, @@ -169,7 +169,7 @@ impl<'a> Engine<'a> { let result = statements .iter() - .try_fold(().into_dynamic(), |_, o| self.eval_stmt(scope, o)); + .try_fold(().into_dynamic(), |_, stmt| self.eval_stmt(scope, stmt)); self.script_functions.clear(); // Clean up engine @@ -261,7 +261,7 @@ impl<'a> Engine<'a> { /// /// let ast = Engine::compile("fn add(x, y) { x.len() + y }")?; /// - /// let result: i64 = engine.call_fn("add", ast, (&mut String::from("abc"), &mut 123_i64))?; + /// let result: i64 = engine.call_fn("add", &ast, (&mut String::from("abc"), &mut 123_i64))?; /// /// assert_eq!(result, 126); /// # Ok(()) @@ -270,7 +270,7 @@ impl<'a> Engine<'a> { pub fn call_fn<'f, A: FuncArgs<'f>, T: Any + Clone>( &mut self, name: &str, - ast: AST, + ast: &AST, args: A, ) -> Result { let pos = Default::default(); @@ -317,7 +317,7 @@ impl<'a> Engine<'a> { /// } /// assert_eq!(result, "42"); /// ``` - pub fn on_print(&mut self, callback: impl FnMut(&str) + 'a) { + pub fn on_print(&mut self, callback: impl FnMut(&str) + 'e) { self.on_print = Box::new(callback); } @@ -337,7 +337,7 @@ impl<'a> Engine<'a> { /// } /// assert_eq!(result, "\"hello\""); /// ``` - pub fn on_debug(&mut self, callback: impl FnMut(&str) + 'a) { + pub fn on_debug(&mut self, callback: impl FnMut(&str) + 'e) { self.on_debug = Box::new(callback); } } diff --git a/tests/engine.rs b/tests/engine.rs index 082daaa4..8db972c4 100644 --- a/tests/engine.rs +++ b/tests/engine.rs @@ -6,7 +6,7 @@ fn test_engine_call_fn() -> Result<(), EvalAltResult> { let ast = Engine::compile("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, (&mut String::from("abc"), &mut 123_i64))?; assert_eq!(result, 126);