Trait Evaler

Source
pub trait Evaler: Debug {
    // Required methods
    fn eval(
        &self,
        slab: &Slab,
        ns: &mut impl EvalNamespace,
    ) -> Result<f64, Error>;
    fn _var_names(&self, slab: &Slab, dst: &mut BTreeSet<String>);

    // Provided method
    fn var_names(&self, slab: &Slab) -> BTreeSet<String> { ... }
}
Expand description

You must use this trait so you can call .eval().

Required Methods§

Source

fn eval(&self, slab: &Slab, ns: &mut impl EvalNamespace) -> Result<f64, Error>

Evaluate this Expression/Instruction and return an f64.

Returns a fasteval::Error if there are any problems, such as undefined variables.

Source

fn _var_names(&self, slab: &Slab, dst: &mut BTreeSet<String>)

Don’t call this directly. Use var_names() instead.

This exists because of ternary short-circuits; they prevent us from getting a complete list of vars just by doing eval() with a clever callback.

Provided Methods§

Source

fn var_names(&self, slab: &Slab) -> BTreeSet<String>

Returns a list of variables and custom functions that are used by this Expression/Instruction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§