Shape

Trait Shape 

Source
pub trait Shape:
    Clone
    + Debug
    + Default
    + Hash
    + Ord
    + Send
    + Sync {
    type Head: Dim;
    type Tail: Shape;
    type Reverse: Shape;
    type Prepend<D: Dim>: Shape;
    type Dyn: Shape;
    type Merge<S: Shape>: Shape;
    type Layout<L: Layout>: Layout;
    type Owned<T>: Owned<T, Self>;

    const RANK: Option<usize>;

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

Array shape trait.

Required Associated Constants§

Source

const RANK: Option<usize>

Array rank if known statically, or None if dynamic.

Required Associated Types§

Source

type Head: Dim

First dimension.

Source

type Tail: Shape

Shape excluding the first dimension.

Source

type Reverse: Shape

Shape with the reverse ordering of dimensions.

Source

type Prepend<D: Dim>: Shape

Prepend the dimension to the shape.

Source

type Dyn: Shape

Corresponding shape with dynamically-sized dimensions.

Source

type Merge<S: Shape>: Shape

Merge each dimension pair, where constant size is preferred over dynamic. The result has dynamic rank if at least one of the inputs has dynamic rank.

Source

type Layout<L: Layout>: Layout

Select layout L for rank 0, or Strided for rank >0 or dynamic.

Source

type Owned<T>: Owned<T, Self>

Corresponding array type owning its contents.

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 from_dims(dims: &[usize]) -> Self

Creates an array shape with the given dimensions.

§Panics

Panics if the dimensions are not matching static rank or constant-sized dimensions.

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.

Implementations on Foreign Types§

Source§

impl Shape for ()

Source§

impl<X: Dim> Shape for (X,)

Source§

const RANK: Option<usize>

Source§

type Head = X

Source§

type Tail = ()

Source§

type Reverse = (X,)

Source§

type Prepend<D: Dim> = (D, X)

Source§

type Dyn = (usize,)

Source§

type Merge<S: Shape> = <<S as Shape>::Tail as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

Source§

type Layout<L: Layout> = Strided

Source§

type Owned<T> = <X as Dim>::Owned<T, ()>

Source§

impl<X: Dim, Y: Dim> Shape for (X, Y)

Source§

const RANK: Option<usize>

Source§

type Head = X

Source§

type Tail = (Y,)

Source§

type Reverse = (Y, X)

Source§

type Prepend<D: Dim> = (D, X, Y)

Source§

type Dyn = <<<(X, Y) as Shape>::Tail as Shape>::Dyn as Shape>::Prepend<usize>

Source§

type Merge<S: Shape> = <<<(X, Y) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

Source§

type Layout<L: Layout> = Strided

Source§

type Owned<T> = <X as Dim>::Owned<T, <(X, Y) as Shape>::Tail>

Source§

impl<X: Dim, Y: Dim, Z: Dim> Shape for (X, Y, Z)

Source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim> Shape for (X, Y, Z, W)

Source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim> Shape for (X, Y, Z, W, U)

Source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, V: Dim> Shape for (X, Y, Z, W, U, V)

Implementors§