https://github.com/asze17/expr.rs
A safe and simple math evaluator for Rust and Python.
https://github.com/asze17/expr.rs
Last synced: 4 months ago
JSON representation
A safe and simple math evaluator for Rust and Python.
- Host: GitHub
- URL: https://github.com/asze17/expr.rs
- Owner: Cryptex-github
- License: mit
- Created: 2022-05-29T18:16:47.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-21T06:41:29.000Z (almost 4 years ago)
- Last Synced: 2025-01-24T00:06:50.675Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# expr.rs
A safe and simple math evaluator for Rust.
Rust rewrite of [expr.py](https://github.com/jay3332/expr.py)
## Features
Basic operations such as
- addition
- subtraction
- multiplication
- division
- modulo
- exponentiation
- negation
- factorial
are supported
Features like sin, cos, tan, log, and more are planned for the future.
A python interface is also planned for the future.
## Usage
```rust
use expr_rs::parser;
assert_eq!(parser::eval("1 + 2").unwrap().to_string(), "3");
```
In Python
```py
import expr_rs
assert expr_rs.eval("1 + 2") == 3
```
In CLI
```bash
cargo install expr_rs
expr 1 + 2
```