rhai/examples/reuse_scope.rs

15 lines
343 B
Rust
Raw Normal View History

2020-03-24 09:49:08 +08:00
use rhai::{Engine, EvalAltResult, Scope, INT};
2016-03-04 08:45:43 -05:00
fn main() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
2019-09-18 11:21:07 +01:00
let mut scope = Scope::new();
2016-03-04 08:45:43 -05:00
engine.eval_with_scope::<()>(&mut scope, "let x = 4 + 5")?;
2016-03-04 08:45:43 -05:00
2020-03-24 09:49:08 +08:00
let result = engine.eval_with_scope::<INT>(&mut scope, "x")?;
2020-03-09 16:54:43 +08:00
println!("result: {}", result);
Ok(())
2016-03-04 08:45:43 -05:00
}