Trait Operator

Source
pub trait Operator {
    // Required method
    fn evaluate(
        &self,
        args: &[Expression],
        scope: &mut Scope,
    ) -> EggResult<Value>;
}
Expand description

Trait for functions defined Rust, callable in Egg. Operators then need to be registered into the operators map, during script evaluation.

Required Methods§

Source

fn evaluate(&self, args: &[Expression], scope: &mut Scope) -> EggResult<Value>

Invokes this Operator.

[args] are the arguments to the Operator, as Expressions. To get a Value from an argument, use the evaluate function.

[scope] is the current scope, where variables are stored. A local scope if the function is called from a user-defined function, or the global scope if called from the main script.

[operators] is a map of all other operators; Can be used directly, but it’s main use is to invoke evaluate on arguments.

Implementors§