diff --git a/examples/reuse_scope.rs b/examples/reuse_scope.rs new file mode 100644 index 00000000..7635a4f9 --- /dev/null +++ b/examples/reuse_scope.rs @@ -0,0 +1,14 @@ +extern crate rhai; +use rhai::{Engine, Scope}; + +fn main() { + let mut engine = Engine::new(); + let mut scope: Scope = Vec::new(); + + if let Ok(_) = engine.eval_with_scope(&mut scope, "var x = 4 + 5".to_string()) { } else { assert!(false); } + + if let Ok(result) = engine.eval_with_scope(&mut scope, "x".to_string()).unwrap().downcast::() { + println!("result: {}", result); + } +} + diff --git a/src/lib.rs b/src/lib.rs index 7386c075..4bcadd15 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,19 +1,8 @@ //! Rhai - embedded scripting for Rust - -// Todo (in no particular order): -// * Doc some examples -// * Maintaining state -// * Overloading -// * How it works -// * Vectors -// * Tighten parser? -// * Errors with positions? - mod engine; - mod fn_register; mod parser; -pub use engine::Engine; +pub use engine::{Engine, Scope}; pub use fn_register::FnRegister;