rustorm/util.rs
1extern crate meval;
2
3fn trim_parenthesis(arg: &str) -> &str {
4 arg.trim_start_matches('(').trim_end_matches(')')
5}
6
7pub fn maybe_trim_parenthesis(arg: &str) -> &str {
8 if arg.starts_with('(') && arg.ends_with(')') {
9 trim_parenthesis(arg)
10 } else {
11 arg
12 }
13}
14
15pub fn eval_f64(expr: &str) -> Result<f64, meval::Error> {
16 meval::eval_str(expr)
17}