Wrapper function of the resolver crate. Provides python-like built-in functions.
Add the following line to your Cargo.toml file (under [dependencies]
):
eval-utility = "0.2"
See test cases in lib.rs
for more examples.
use eval_utility::eval_wrapper::{EvalConfig, ExprWrapper};
fn main() {
let expression = "float('42.42') == 42.42";
let expected = true;
let expr = ExprWrapper::new(expression)
// .config(Default::default())
.config(EvalConfig { // same as Default::default() ^
include_maths: true,
include_regex: true,
include_datetime: true,
include_cast: true,
})
.init();
match expr.exec() {
Ok(value) => {
assert_eq!(value, expected);
}
Err(err) => {
panic!("err={err:?}");
}
};
// ...
}