casbin::rhai

Function eval

pub fn eval<T>(script: &str) -> Result<T, Box<EvalAltResult>>
where T: Variant + Clone,
Expand description

Evaluate a string as a script, returning the result value or an error.

ยงExample

let result: i64 = rhai::eval("40 + 2")?;

assert_eq!(result, 42);