Crates.io | clc-engine |
lib.rs | clc-engine |
version | 0.1.4 |
source | src |
created_at | 2022-03-27 05:13:50.369483 |
updated_at | 2022-03-30 16:09:29.97404 |
description | Provide calculation api for calculator ui |
homepage | |
repository | https://github.com/ymgyt/calculator |
max_upload_size | |
id | 557164 |
size | 37,572 |
[Calculator
] calculate given expression.
Core functionality for clc.
use clc_engine::Calculator;
let clc = Calculator::new();
let eval = clc.calculate_line("sqrt(sqrt(16)) * (4 + 2)");
assert_eq!(eval, Ok(12.));
use clc_engine::{Calculator, Error,EvalError};
let clc = Calculator::new();
let err = clc.calculate_line("10 / 0");
assert_eq!(err, Err(Error::Eval(EvalError::DivisionByZero)));
Under the hood clc-engine use nom to parse expression
This project is available under the terms of either the Apache 2.0 license or the MIT license.