Function eval

Source
pub fn eval<T>(expression: T) -> Result<f64>
where T: AsRef<str>,
Expand description

Evaluates a numeric expression.

The expression can contain integers, floats, sums, subtractions, multiplications, divisions and can use parentheses. Whitespace is ignored. Floating point numbers must be represented in the X.Y form, where X and Y are non-empty sequence of digits. The notation with the exponent is not currently supported.

T: type of the expression. Usually a &str or a String.

let x = mexe::eval("2 * (1 + 1)")?;

ยงErrors

This function will return a MexeError if the input is not a valid arithmetic expression.