Mapping

Trait Mapping 

Source
pub trait Mapping:
    Clone
    + Debug
    + Default
    + Eq
    + Hash
    + Send
    + Sync {
    type Shape: Shape;
    type Layout: Layout<Mapping<Self::Shape> = Self>;

    // Required methods
    fn is_contiguous(&self) -> bool;
    fn shape(&self) -> &Self::Shape;
    fn stride(&self, index: usize) -> isize;

    // Provided methods
    fn dim(&self, index: usize) -> usize { ... }
    fn dims(&self) -> &[usize]
       where Self: Mapping<Shape = DynRank> { ... }
    fn is_empty(&self) -> bool { ... }
    fn len(&self) -> usize { ... }
    fn rank(&self) -> usize { ... }
}
Expand description

Array layout mapping trait, including shape and strides.

Required Associated Types§

Source

type Shape: Shape

Array shape type.

Source

type Layout: Layout<Mapping<Self::Shape> = Self>

Array layout type.

Required Methods§

Source

fn is_contiguous(&self) -> bool

Returns true if the array strides are consistent with contiguous memory layout.

Source

fn shape(&self) -> &Self::Shape

Returns the array shape.

Source

fn stride(&self, index: usize) -> isize

Returns the distance between elements in the specified dimension.

§Panics

Panics if the dimension is out of bounds.

Provided Methods§

Source

fn dim(&self, index: usize) -> usize

Returns the number of elements in the specified dimension.

§Panics

Panics if the dimension is out of bounds.

Source

fn dims(&self) -> &[usize]
where Self: Mapping<Shape = DynRank>,

Returns the number of elements in each dimension.

Source

fn is_empty(&self) -> bool

Returns true if the array contains no elements.

Source

fn len(&self) -> usize

Returns the number of elements in the array.

Source

fn rank(&self) -> usize

Returns the array rank, i.e. the number of dimensions.

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.

Implementors§