This repository has been archived on 2025-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
rhaj/rhai_engine/rhaiexamples/hello.rs
2025-04-03 09:18:05 +02: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(())
}