#expression-evaluator #evaluate #eval #context #value

v_eval

Expression evaluator with context

12 releases (6 breaking)

0.6.0 May 5, 2020
0.5.3 Apr 28, 2020
0.4.1 Apr 26, 2020
0.3.0 Apr 14, 2020
0.0.2 Mar 18, 2019

#15 in #eval

Download history 230/week @ 2024-08-01 198/week @ 2024-08-08 224/week @ 2024-08-15 271/week @ 2024-08-22 234/week @ 2024-08-29 197/week @ 2024-09-05 192/week @ 2024-09-12 192/week @ 2024-09-19 272/week @ 2024-09-26 289/week @ 2024-10-03 246/week @ 2024-10-10 231/week @ 2024-10-17 176/week @ 2024-10-24 258/week @ 2024-10-31 204/week @ 2024-11-07 155/week @ 2024-11-14

821 downloads per month
Used in 8 crates (via yarte_hir)

MIT/Apache

75KB
1.5K SLoC

v_eval Documentation Latest version

Expression evaluator with context

use v_eval::{Value, Eval};

fn main() -> Result<(), ()> {
    let e = Eval::default()
        .insert("foo", "true")?
        .insert("bar", "false")?;

    assert_eq!(e.eval("foo != bar").unwrap(), Value::Bool(true));
    assert_eq!(
        e.eval("true && foo != bar && true").unwrap(),
        Value::Bool(true)
    );
    assert_eq!(e.eval("1 == 1 != bar").unwrap(), Value::Bool(true));
    assert_eq!(e.eval("1 == 1 + 1 == bar").unwrap(), Value::Bool(true));
    
    Ok(())
}

Contributing

Please, contribute to v_eval! The more the better! Feel free to to open an issue and/or contacting directly with the owner for any request or suggestion.

Code of conduct

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4

License

This project is distributed under the terms of both the Apache License (Version 2.0) and the MIT license, specified in LICENSE-APACHE and LICENSE-MIT respectively.

Dependencies

~3.5–4.5MB
~91K SLoC