#evaluate #eval #panic #evaluate-expressions

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

#1166 in Rust patterns

Download history 217/week @ 2023-10-22 223/week @ 2023-10-29 248/week @ 2023-11-05 261/week @ 2023-11-12 253/week @ 2023-11-19 318/week @ 2023-11-26 182/week @ 2023-12-03 218/week @ 2023-12-10 238/week @ 2023-12-17 228/week @ 2023-12-24 142/week @ 2023-12-31 220/week @ 2024-01-07 348/week @ 2024-01-14 257/week @ 2024-01-21 197/week @ 2024-01-28 326/week @ 2024-02-04

1,157 downloads per month
Used in 7 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–4.5MB
~86K SLoC