pub trait FunctionExpression: Send + Sync + Debug + DynClone + Clone + 'static {
    // Required methods
    fn resolve(&self, ctx: &mut Context<'_>) -> Resolved;
    fn type_def(&self, state: &TypeState) -> TypeDef;

    // Provided methods
    fn as_value(&self) -> Option<Value> { ... }
    fn as_expr(&self) -> Box<dyn Expression> { ... }
}
Expand description

A trait similar to Expression, but simplified specifically for functions. The main difference is this trait prevents mutation of variables both at runtime and compile time.

Required Methods§

source

fn resolve(&self, ctx: &mut Context<'_>) -> Resolved

Resolve an expression to a concrete Value. This method is executed at runtime. An expression is allowed to fail, which aborts the running program.

source

fn type_def(&self, state: &TypeState) -> TypeDef

The resulting type that the function resolves to.

Provided Methods§

source

fn as_value(&self) -> Option<Value>

Resolves values at compile-time for constant functions.

This returns Some for constant expressions, or None otherwise.

source

fn as_expr(&self) -> Box<dyn Expression>

Converts this function to a normal Expression.

Object Safety§

This trait is not object safe.

Implementors§