| Crates.io | evalbit |
| lib.rs | evalbit |
| version | 0.1.2 |
| created_at | 2025-10-21 09:24:28.879448+00 |
| updated_at | 2025-10-22 06:48:15.464952+00 |
| description | A simple logical expression evaluation crate with RPN conversion |
| homepage | |
| repository | https://github.com/Ablaze-MIRAI/evalbit |
| max_upload_size | |
| id | 1893551 |
| size | 18,026 |
A simple logical expression evaluation crate with RPN convertion
Add evalbit as dependency to your Cargo.toml:
[dependencies]
evalbit = "<desired version>"
Then you can use evalbit to parse and evaluate expressions like this:
use evalbit::*;
let expr = "0 | (1 ^ 2 & 3)"
let rpn = parse(expr);
assert_eq!(rpn.to_string(), "0 1 2 3 & ^ |");
assert_eq!(rpn.exec(&[true, true, false, false]), true);
// and you can directly execute
assert_eq!(eval("0 | (1 ^ 2 & 3)", &[true, true, false, false]), true));
The operator precedences are equal to Rust's ones.
This crate is published under the ISC License.