Function dust_lib::eval_with_context
source · pub fn eval_with_context(
input: &str,
context: &mut VariableMap
) -> Result<Value>Expand description
Evaluate the given expression string with the given context.
Examples
let mut context = VariableMap::new();
context.set_value("one".into(), 1.into()).unwrap(); // Do proper error handling here
context.set_value("two".into(), 2.into()).unwrap(); // Do proper error handling here
context.set_value("three".into(), 3.into()).unwrap(); // Do proper error handling here
assert_eq!(eval_with_context("one + two + three", &mut context), Ok(Value::from(6)));