ResizeLayout

Trait ResizeLayout 

Source
pub trait ResizeLayout: MutLayout {
    // Required methods
    fn insert_axis(&mut self, index: usize);
    fn remove_axis_of_any_size(&mut self, index: usize);
    fn merge_axes(&mut self);

    // Provided method
    fn remove_axis(&mut self, index: usize) { ... }
}
Expand description

Trait which extends MutLayout with support for changing the number of dimensions in-place.

This is only implemented for DynLayout, since layouts that have a static rank cannot change their dimension count at runtime.

Required Methods§

Source

fn insert_axis(&mut self, index: usize)

Insert a size-one axis at the given index in the shape. This will have the same stride as the dimension that follows it.

Source

fn remove_axis_of_any_size(&mut self, index: usize)

Remove an axis that may have any size.

If the size of the axis is not one, this will “remove” elements from the layout.

Source

fn merge_axes(&mut self)

Merge consecutive axes where possible.

This “simplifies” the layout by minimizing the number of dimensions while preserving the iteration order.

Provided Methods§

Source

fn remove_axis(&mut self, index: usize)

Remove a size-1 axis at the given index.

Since the axis has size one, this does not alter the number of elements in the layout or the order in which they are visited.

Panics if the axis does not have a size of 1.

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§