Condition

Trait Condition 

Source
pub trait Condition<S: HasComponent<Component>> {
    const DOC: Option<&'static str> = None;

    // Required method
    fn evaluate(input: &mut ExpansionInput<S>) -> Result<bool>;

    // Provided method
    fn build_if_command() -> BuiltIn<S> { ... }
}
Expand description

Logical condition used to build if conditional commands.

This trait can be used to build new conditional commands outside of this module. To do this, just create a new type (generally a ZST) and implement the evaluate method of the trait for the type. A conditional command that uses the condition can then be obtained using the build_if_command method.

Provided Associated Constants§

Source

const DOC: Option<&'static str> = None

Optional documentation for the command built using this condition.

Required Methods§

Source

fn evaluate(input: &mut ExpansionInput<S>) -> Result<bool>

Evaluate the condition.

Returns true if the condition is true, false if it is false, and an error otherwise.

Provided Methods§

Source

fn build_if_command() -> BuiltIn<S>

Build an if conditional command that uses this condition.

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§