rhai/examples/hello.rs
2022-10-27 13:38:21 +08:00

16 lines
350 B
Rust

//! A simple example that evaluates an expression and prints the result.
use rhai::{Engine, EvalAltResult};
fn main() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
engine.run(r#"print("hello, world!")"#)?;
let result = engine.eval::<i64>("40 + 2")?;
println!("The Answer: {result}"); // prints 42
Ok(())
}