Crates.io | g_calc |
lib.rs | g_calc |
version | 0.1.1 |
source | src |
created_at | 2022-09-19 04:00:16.176322 |
updated_at | 2022-09-19 04:42:45.082295 |
description | A small utility for performing simple math calculations using infix expression |
homepage | |
repository | |
max_upload_size | |
id | 668906 |
size | 8,655 |
Simple calculator utility written in rust
Add this to your Cargo.toml:
[dependencies]
g_calc = "0.1.1"
use g_calc::{convert,solve};
let sample_expr = "1 + 2 * 3";
//this fn converts the given infix expression to postfix expression
let postfix_expr = g_calc::convert(sample_expr).unwrap();
//this fn solves the postfix expression and returns the result
let output = g_calc::solve(postfix_expr).unwrap();
// output = 7
works for basic math calculations