clc-engine

Crates.ioclc-engine
lib.rsclc-engine
version0.1.4
sourcesrc
created_at2022-03-27 05:13:50.369483
updated_at2022-03-30 16:09:29.97404
descriptionProvide calculation api for calculator ui
homepage
repositoryhttps://github.com/ymgyt/calculator
max_upload_size
id557164
size37,572
Yuta Yamaguchi (ymgyt)

documentation

README

clc-engine

clc-engine on crates.io Documentation (latest release) Changelog License License

[Calculator] calculate given expression. Core functionality for clc.

Examples

use clc_engine::Calculator;

let clc = Calculator::new();
let eval = clc.calculate_line("sqrt(sqrt(16)) * (4 + 2)");

assert_eq!(eval, Ok(12.));

Division by zero

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

License

This project is available under the terms of either the Apache 2.0 license or the MIT license.

Commit count: 188

cargo fmt