pub trait Expr<T: Clone> {
// Required methods
fn eval_at(&self, index: usize) -> T;
fn size(&self) -> usize;
fn shape(&self) -> &[usize];
// Provided methods
fn eval(&self) -> Array<T> { ... }
fn can_fuse_with<E: Expr<T>>(&self, other: &E) -> bool { ... }
}Expand description
Trait for lazy expressions that can be evaluated
All expression types (binary ops, unary ops, arrays) implement this trait to enable deferred computation and optimization.
Required Methods§
Provided Methods§
Sourcefn eval(&self) -> Array<T>
fn eval(&self) -> Array<T>
Materialize the expression into an Array
This triggers evaluation of the entire expression tree, applying all optimizations and fusions.
Sourcefn can_fuse_with<E: Expr<T>>(&self, other: &E) -> bool
fn can_fuse_with<E: Expr<T>>(&self, other: &E) -> bool
Check if this expression can be fused with another
Returns true if the expressions have compatible shapes for fusion.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".