pub unsafe trait Dimension: Clone + Eq {
// Required method
fn ndim(&self) -> usize;
// Provided methods
fn slice(&self) -> &[Ix] { ... }
fn slice_mut(&mut self) -> &mut [Ix] { ... }
fn size(&self) -> usize { ... }
fn default_strides(&self) -> Self { ... }
fn first_index(&self) -> Option<Self> { ... }
fn next_for(&self, index: Self) -> Option<Self> { ... }
fn stride_offset(index: &Self, strides: &Self) -> isize { ... }
fn stride_offset_checked(
&self,
strides: &Self,
index: &Self,
) -> Option<isize> { ... }
fn do_slices(dim: &mut Self, strides: &mut Self, slices: &[Si]) -> isize { ... }
}
Expand description
Trait for the shape and index types of arrays.
unsafe trait due to how the assumptions in the default impls work.
Required Methods§
Provided Methods§
fn slice(&self) -> &[Ix]
fn slice_mut(&mut self) -> &mut [Ix]
fn size(&self) -> usize
fn default_strides(&self) -> Self
fn first_index(&self) -> Option<Self>
sourcefn next_for(&self, index: Self) -> Option<Self>
fn next_for(&self, index: Self) -> Option<Self>
Iteration – Use self as size, and return next index after index
or None if there are no more.
sourcefn stride_offset(index: &Self, strides: &Self) -> isize
fn stride_offset(index: &Self, strides: &Self) -> isize
Return stride offset for index.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl Dimension for (Ix, Ix)
impl Dimension for (Ix, Ix)
source§fn stride_offset(index: &(Ix, Ix), strides: &(Ix, Ix)) -> isize
fn stride_offset(index: &(Ix, Ix), strides: &(Ix, Ix)) -> isize
Self is an index, return the stride offset
source§fn stride_offset_checked(
&self,
strides: &(Ix, Ix),
index: &(Ix, Ix),
) -> Option<isize>
fn stride_offset_checked( &self, strides: &(Ix, Ix), index: &(Ix, Ix), ) -> Option<isize>
Return stride offset for this dimension and index.