rhai/examples/reuse_scope.rs

15 lines
351 B
Rust
Raw Normal View History

2020-03-09 09:54:43 +01:00
use rhai::{Engine, EvalAltResult, Scope};
2016-03-04 14:45:43 +01:00
2020-03-09 09:54:43 +01:00
fn main() -> Result<(), EvalAltResult> {
2016-03-04 14:45:43 +01:00
let mut engine = Engine::new();
2019-09-18 12:21:07 +02:00
let mut scope = Scope::new();
2016-03-04 14:45:43 +01:00
engine.eval_with_scope::<()>(&mut scope, false, "let x = 4 + 5")?;
2016-03-04 14:45:43 +01:00
let result = engine.eval_with_scope::<i64>(&mut scope, false, "x")?;
2020-03-09 09:54:43 +01:00
println!("result: {}", result);
Ok(())
2016-03-04 14:45:43 +01:00
}