rhai/examples/hello.rs
2020-05-13 19:39:34 +08:00

13 lines
310 B
Rust

use rhai::{packages::*, Engine, EvalAltResult, INT};
fn main() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new_raw();
engine.load_package(ArithmeticPackage::new().get());
let result = engine.eval::<INT>("40 + 2")?;
println!("Answer: {}", result); // prints 42
Ok(())
}