#python #evaluator #safe #math #rust #command-line-utlilities

bin+lib expr_rs

A safe and simple math evaluator for Rust and Python

1 unstable release

0.0.0 May 30, 2022

#47 in #evaluator

MIT license

10KB
196 lines

expr.rs

A safe and simple math evaluator for Rust.

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

use expr_rs::parser;

assert_eq!(parser::eval("1 + 2").unwrap().to_string(), "3");

In Python

import expr_rs

assert expr_rs.eval("1 + 2") == 3

In CLI

cargo install expr_rs

expr 1 + 2

lib.rs:

Expr.rs - A safe and simple math evaluator for Rust and Python.

Dependencies

~1.2–7MB
~44K SLoC