eval-utility

Crates.ioeval-utility
lib.rseval-utility
version0.2.2
created_at2022-07-14 21:10:49.160932+00
updated_at2025-05-16 22:56:55.871746+00
descriptionWrapper function of the evaluator crate. Provides python-like built-in functions.
homepagehttps://github.com/floating-floaties/eval-utility/
repositoryhttps://github.com/floating-floaties/eval-utility/
max_upload_size
id625907
size83,066
0x (0xBADC0FFEE0DDF00D)

documentation

README

Eval Utility

About

Wrapper function of the resolver crate. Provides python-like built-in functions.

Install

Add the following line to your Cargo.toml file (under [dependencies]):

eval-utility = "0.2"

Example

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 mut 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:?}");
        }
    };
    // ...
}
Commit count: 38

cargo fmt