Trait meval::Context [] [src]

pub trait Context {
    fn get_var(&self, _: &str) -> Option<f64> { ... }
    fn eval_func(&self, _: &str, _: &[f64]) -> Result<f64FuncEvalError> { ... }
}

Values of variables (and constants) for substitution into an evaluated expression.

The built in context is given by the builtin() function (or the Builtins type).

A Context can be built from other contexts:

use meval::Context;

let bins = meval::builtin(); // built-ins
assert_eq!(bins.get_var("pi"), Some(std::f64::consts::PI));

let myvars = ("x", 2.);
assert_eq!(myvars.get_var("x"), Some(2f64));

// contexts can be combined using tuples
let ctx = (myvars, bins); // first context has preference if there's duplicity

assert_eq!(meval::eval_str_with_context("x * pi", ctx).unwrap(), 2. * std::f64::consts::PI);

Provided Methods

fn get_var(&self, _: &str) -> Option<f64>

fn eval_func(&self, _: &str, _: &[f64]) -> Result<f64FuncEvalError>

Implementors