rhai/examples/hello.rs

16 lines
352 B
Rust
Raw Normal View History

2022-02-12 05:41:04 +01:00
//! A simple example that evaluates an expression and prints the result.
use rhai::{Engine, EvalAltResult};
fn main() -> Result<(), Box<EvalAltResult>> {
2020-10-07 09:52:24 +02:00
let engine = Engine::new();
engine.run(r#"print("hello, world!")"#)?;
2021-02-20 16:46:25 +01:00
let result = engine.eval::<i64>("40 + 2")?;
2020-03-09 09:54:43 +01:00
2022-02-10 05:54:30 +01:00
println!("The Answer: {}", result); // prints 42
2020-03-09 09:54:43 +01:00
Ok(())
2017-12-20 12:16:14 +01:00
}