pub trait Expression: IntoIterator {
type Shape: Shape;
const IS_REPEATABLE: bool;
Show 17 methods
// Required method
fn shape(&self) -> &Self::Shape;
// Provided methods
fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
where Self: Expression<Item = &'a T> + Sized { ... }
fn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
where Self: Expression<Item = &'a T> + Sized { ... }
fn dim(&self, index: usize) -> usize { ... }
fn enumerate(self) -> Enumerate<Self>
where Self: Sized { ... }
fn eq<I: IntoExpression>(self, other: I) -> bool
where Self: Expression<Item: PartialEq<I::Item>> + Sized { ... }
fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
where Self: Sized,
F: FnMut(Self::Item, I::Item) -> bool { ... }
fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>
where Self: Sized { ... }
fn eval_into<S: Shape, A: Allocator>(
self,
tensor: &mut Tensor<Self::Item, S, A>,
) -> &mut Tensor<Self::Item, S, A>
where Self: Sized { ... }
fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> T
where Self: Sized { ... }
fn for_each<F: FnMut(Self::Item)>(self, f: F)
where Self: Sized { ... }
fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... }
fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>
where Self: Sized { ... }
fn ne<I: IntoExpression>(self, other: I) -> bool
where Self: Expression<Item: PartialEq<I::Item>> + Sized { ... }
fn rank(&self) -> usize { ... }
fn zip<I: IntoExpression>(self, other: I) -> Zip<Self, I::IntoExpr>
where Self: Sized { ... }
}Expand description
Expression trait, for multidimensional iteration.
Required Associated Constants§
Sourceconst IS_REPEATABLE: bool
const IS_REPEATABLE: bool
True if the expression can be restarted from the beginning after the last element.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
Creates an expression which clones all of its elements.
Sourcefn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
fn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
Creates an expression which copies all of its elements.
Sourcefn dim(&self, index: usize) -> usize
fn dim(&self, index: usize) -> usize
Returns the number of elements in the specified dimension.
§Panics
Panics if the dimension is out of bounds.
Sourcefn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Creates an expression which gives tuples of the current count and the element.
Sourcefn eq<I: IntoExpression>(self, other: I) -> bool
fn eq<I: IntoExpression>(self, other: I) -> bool
Determines if the elements of the expression are equal to those of another.
Sourcefn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
Determines if the elements of the expression are equal to those of another with respect to the specified equality function.
Sourcefn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>where
Self: Sized,
fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>where
Self: Sized,
Evaluates the expression into a new array.
The resulting type is Array if the shape has constant-sized dimensions, or
otherwise Tensor. If the shape type is generic, FromExpression::from_expr
can be used to evaluate the expression into a specific array type.
Sourcefn eval_into<S: Shape, A: Allocator>(
self,
tensor: &mut Tensor<Self::Item, S, A>,
) -> &mut Tensor<Self::Item, S, A>where
Self: Sized,
fn eval_into<S: Shape, A: Allocator>(
self,
tensor: &mut Tensor<Self::Item, S, A>,
) -> &mut Tensor<Self::Item, S, A>where
Self: Sized,
Evaluates the expression with broadcasting and appends to the given array along the first dimension.
If the array is empty, it is reshaped to match the shape of the expression.
§Panics
Panics if the inner dimensions do not match, if the rank is not the same and at least 1, or if the first dimension is not dynamically-sized.
Sourcefn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> Twhere
Self: Sized,
fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> Twhere
Self: Sized,
Folds all elements into an accumulator by applying an operation, and returns the result.
Sourcefn for_each<F: FnMut(Self::Item)>(self, f: F)where
Self: Sized,
fn for_each<F: FnMut(Self::Item)>(self, f: F)where
Self: Sized,
Calls a closure on each element of the expression.
Sourcefn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>where
Self: Sized,
fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>where
Self: Sized,
Creates an expression that calls a closure on each element.
Sourcefn ne<I: IntoExpression>(self, other: I) -> bool
fn ne<I: IntoExpression>(self, other: I) -> bool
Determines if the elements of the expression are not equal to those of another.
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.