Skip to main content

ScriptExpression

Trait ScriptExpression 

Source
pub trait ScriptExpression: Send + Sync {
    // Required method
    fn evaluate(&self, context: &mut Context, registry: &Registry);
}
Expand description

The extra operations a frontend adds on top of the built-in set.

The built-in operations move data around but never create it, since the platform has no opinion about what data is. Pushing a literal, dropping a value, anything else specific to one language, goes here.

enum MyExpression {
    Literal(i32),
    Drop,
}

impl ScriptExpression for MyExpression {
    fn evaluate(&self, context: &mut Context, _: &Registry) {
        match self {
            Self::Literal(value) => { context.stack().push(*value); }
            Self::Drop => { context.stack().drop(); }
        }
    }
}

Required Methods§

Source

fn evaluate(&self, context: &mut Context, registry: &Registry)

Runs this expression against the running context.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ScriptExpression for ()

Source§

fn evaluate(&self, _: &mut Context, _: &Registry)

Implementors§