13 lines
310 B
Rust
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(())
|
|
}
|