Function exmex::parse_val

source ·
pub fn parse_val<I, F>(text: &str) -> ExResult<FlatExVal<I, F>>
where I: DataType + PrimInt + Signed, F: DataType + Float, <I as FromStr>::Err: Debug, <F as FromStr>::Err: Debug,
Expand description

feature = "value" - Parses a string into an expression of type FlatExVal with datatype Val.

let expr = parse_val::<i32, f64>("x^y")?;
let res = expr.eval(&[Val::Float(2.0), Val::Int(3)])?.to_float()?;
assert!( (res - 8.0).abs() < 1e-12);