pub trait HasShape {
// Required methods
fn num_dims(&self) -> usize;
fn num_elements(&self) -> usize;
fn get_dim(&self, total_dims: usize, i: usize) -> usize;
fn shape(&self) -> &Shape;
}Required Methods§
Sourcefn num_elements(&self) -> usize
fn num_elements(&self) -> usize
Return the number of elements
Sourcefn get_dim(&self, total_dims: usize, i: usize) -> usize
fn get_dim(&self, total_dims: usize, i: usize) -> usize
Return the size of a given dimension within a larger space.
Assumes the defined shape are the inner dimensions and will return 1 when the specified dimension is out of the defined shape.
For example, a shape of the form [2, 4, 5] with calls: shape.get_dim(4, 0) will return 1 (dimension outside of defined shape) shape.get_dim(4, 1) will return 2 shape.get_dim(4, 2) will return 4 shape.get_dim(4, 3) will return 5
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".