rhai/examples/hello.rs
2020-04-21 00:11:25 +08:00

14 lines
322 B
Rust

use rhai::{packages::*, Engine, EvalAltResult, INT};
use std::rc::Rc;
fn main() -> Result<(), 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(())
}