Skip to main content

OperationReflect

Trait OperationReflect 

Source
pub trait OperationReflect: Sized {
    type OpCode;

    // Required method
    fn op_code(&self) -> Self::OpCode;

    // Provided methods
    fn args(&self) -> Option<Vec<Variable>> { ... }
    fn from_code_and_args(
        op_code: Self::OpCode,
        args: &[Variable],
    ) -> Option<Self> { ... }
    fn is_commutative(&self) -> bool { ... }
    fn is_pure(&self) -> bool { ... }
}
Expand description

An operation that can be reflected on

Required Associated Types§

Source

type OpCode

Type of the op codes for this operation

Required Methods§

Source

fn op_code(&self) -> Self::OpCode

Get the opcode for this operation

Provided Methods§

Source

fn args(&self) -> Option<Vec<Variable>>

Get the list of arguments for this operation. If not all arguments are Variable, returns None instead.

Source

fn from_code_and_args(op_code: Self::OpCode, args: &[Variable]) -> Option<Self>

Create typed operation from an opcode and a list of arguments. Returns None if not all arguments are Variable.

Source

fn is_commutative(&self) -> bool

Whether this operation is commutative (arguments can be freely reordered). Ignored for single argument operations.

Source

fn is_pure(&self) -> bool

Whether this operation is pure (has no side effects). Things like uniform/plane operations are considered impure, because they affect other units.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§