Skip to main content

Shape

Trait Shape 

Source
pub trait Shape {
    // Required method
    fn shape(&self) -> ShapeDim;

    // Provided methods
    fn shape_1d(&self) -> usize { ... }
    fn shape_2d(&self) -> (usize, usize) { ... }
    fn shape_3d(&self) -> (usize, usize, usize) { ... }
    fn shape_4d(&self) -> (usize, usize, usize, usize) { ... }
}
Expand description

Shape trait.

Returns a recursively-describable Shape for the receiver.

Includes accessor types for common use cases e.g., shape_1d, shape_2d, which are automatic provided the implementor implements shape.

Required Methods§

Source

fn shape(&self) -> ShapeDim

Returns arbitrary Shape dimension for any data shape

Provided Methods§

Source

fn shape_1d(&self) -> usize

Returns the first dimension shape

Exists to bypass a match on ShapeDim for Array shaped types

Source

fn shape_2d(&self) -> (usize, usize)

Returns the first and second dimension shapes

Exists to bypass a match on ShapeDim for Table shaped types

Source

fn shape_3d(&self) -> (usize, usize, usize)

Returns the first, second and third dimension shapes

Exists to bypass a match on ShapeDim for 3D types

Source

fn shape_4d(&self) -> (usize, usize, usize, usize)

Returns the first, second, third and fourth dimension shapes

Exists to bypass a match on ShapeDim for 4D types

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§