Crates.io | v_eval |
lib.rs | v_eval |
version | 0.6.0 |
source | src |
created_at | 2019-03-18 17:35:28.901401 |
updated_at | 2020-05-05 19:13:06.33938 |
description | Expression evaluator with context |
homepage | |
repository | https://github.com/botika/v_eval |
max_upload_size | |
id | 122287 |
size | 95,034 |
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(())
}
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.
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4
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.