Skip to main content

BuiltinResolver

Trait BuiltinResolver 

Source
pub trait BuiltinResolver {
    // Required methods
    fn handles(&self, op: BuiltinOp) -> bool;
    fn apply(
        &self,
        op: BuiltinOp,
        args: &[Literal],
    ) -> Result<Literal, ExprError>;
}
Expand description

A source of answers for builtins this evaluator cannot compute on its own.

The graph traversal builtins read an instance, which the pure evaluator does not hold. A resolver plugs that context in at every point a builtin is applied — not only at the root of the expression — so a graph builtin nested under a comparison, a binding, a lambda, or a comprehension answers exactly as it would at the top.

Required Methods§

Source

fn handles(&self, op: BuiltinOp) -> bool

Whether this resolver answers for op. Operations it declines are computed by apply_builtin.

Source

fn apply(&self, op: BuiltinOp, args: &[Literal]) -> Result<Literal, ExprError>

Answer op on already-evaluated arguments.

§Errors

Returns ExprError when the arguments are of the wrong number or type, or when the operation fails against the context.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§