https://github.com/zzau13/v_eval
Expression evaluator with context
https://github.com/zzau13/v_eval
evaluate-expressions rust
Last synced: 10 days ago
JSON representation
Expression evaluator with context
- Host: GitHub
- URL: https://github.com/zzau13/v_eval
- Owner: zzau13
- License: apache-2.0
- Created: 2020-04-25T18:05:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-05T10:11:14.000Z (about 1 year ago)
- Last Synced: 2025-05-05T04:17:18.973Z (18 days ago)
- Topics: evaluate-expressions, rust
- Language: Rust
- Homepage:
- Size: 62.5 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# v_eval [](https://docs.rs/v_eval/) [](https://crates.io/crates/v_eval)
Expression evaluator with context
```rust
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][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version][homepage]: http://contributor-covenant.org
[version]: 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](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) respectively.