Remove lifetime from Engine.
This commit is contained in:
@@ -81,18 +81,18 @@ fn test_side_effects_command() -> Result<(), EvalAltResult> {
|
||||
|
||||
#[test]
|
||||
fn test_side_effects_print() -> Result<(), EvalAltResult> {
|
||||
use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
|
||||
let result = RwLock::new(String::from(""));
|
||||
let result = Arc::new(RwLock::new(String::from("")));
|
||||
|
||||
{
|
||||
let mut engine = Engine::new();
|
||||
let mut engine = Engine::new();
|
||||
|
||||
// Override action of 'print' function
|
||||
engine.on_print(|s| result.write().unwrap().push_str(s));
|
||||
// Override action of 'print' function
|
||||
let logger = result.clone();
|
||||
engine.on_print(move |s| logger.write().unwrap().push_str(s));
|
||||
|
||||
engine.consume("print(40 + 2);")?;
|
||||
}
|
||||
engine.consume("print(40 + 2);")?;
|
||||
|
||||
assert_eq!(*result.read().unwrap(), "42");
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user