2020-03-18 12:04:26 +08:00
|
|
|
#![cfg_attr(feature = "no_std", no_std)]
|
|
|
|
|
2020-03-24 09:49:08 +08:00
|
|
|
use rhai::{Engine, EvalAltResult, INT};
|
2020-03-18 12:04:26 +08:00
|
|
|
|
2020-04-24 12:39:24 +08:00
|
|
|
#[cfg(feature = "no_std")]
|
|
|
|
extern crate alloc;
|
|
|
|
|
|
|
|
#[cfg(feature = "no_std")]
|
|
|
|
use alloc::boxed::Box;
|
|
|
|
|
2020-04-21 23:25:12 +08:00
|
|
|
fn main() -> Result<(), Box<EvalAltResult>> {
|
2020-04-07 13:23:06 +08:00
|
|
|
let engine = Engine::new();
|
2020-03-18 12:04:26 +08:00
|
|
|
|
2020-03-24 09:49:08 +08:00
|
|
|
let result = engine.eval::<INT>("40 + 2")?;
|
2020-03-18 12:04:26 +08:00
|
|
|
|
2020-03-24 11:21:09 +08:00
|
|
|
#[cfg(not(feature = "no_std"))]
|
|
|
|
println!("Answer: {}", result);
|
|
|
|
|
|
|
|
#[cfg(feature = "no_std")]
|
|
|
|
assert_eq!(result, 42);
|
2020-03-18 12:04:26 +08:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|