//! An example that evaluates two pieces of code in separate runs, but using a common `Scope`. use rhai::{Engine, EvalAltResult, Scope}; fn main() -> Result<(), Box> { let engine = Engine::new(); let mut scope = Scope::new(); engine.run_with_scope(&mut scope, "let x = 4 + 5")?; println!("x = {}", scope.get_value::("x").unwrap()); for _ in 0..10 { let result = engine.eval_with_scope::(&mut scope, "x += 1; x")?; println!("result: {result}"); } println!("x = {}", scope.get_value::("x").unwrap()); Ok(()) }