[][src]Crate mathew

Evaluate some syn::Expr with context and float methods

use mathew::Eval;

let e = Eval::default()
    .insert("foo", "1")?
    .insert("bar", "0")?;

assert_eq!(e.eval("1 + bar").unwrap(), 1.0);

assert_eq!(e.eval("foo + bar").unwrap(), 1.0);

assert_eq!(e.eval("2.5.powi(2 * foo)").unwrap(), 6.25);

Value type

Default value type is f32 but you can change to f64 with feature double

Structs

Eval

Mathematical expression evaluator with context

Functions

ctx_as_ref

Cast context elements to references

eval

Type Definitions

Value