Crates.io | mathew |
lib.rs | mathew |
version | 0.0.2 |
source | src |
created_at | 2019-03-19 15:22:34.715423 |
updated_at | 2019-03-19 22:18:36.623061 |
description | Mathematical expression evaluator with context |
homepage | |
repository | https://gitlab.com/r-iendo/mathew |
max_upload_size | |
id | 122481 |
size | 37,680 |
Mathematical expression evaluator with context and float methods
use mathew::Eval;
fn main() -> Result<(), ()> {
let e = Eval::default().insert("foo", "1")?.insert("bar", "0")?;
assert_eq!(e.eval("foo + bar").unwrap(), 1.0);
assert_eq!(e.eval("foo - bar * 1").unwrap(), 1.0);
assert_eq!(e.eval("1 + bar").unwrap(), 1.0);
assert_eq!(e.eval("2.5.powi(2 * foo)").unwrap(), 6.25);
Ok(())
}
Please, contribute to mathew! 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.