Skip to main content

SizeArray

Trait SizeArray 

Source
pub trait SizeArray:
    Clone
    + Debug
    + PartialEq<Self> {
    // Required methods
    fn len(&self) -> usize;
    fn get(&self, index: usize) -> Option<usize>;
    fn iter(&self) -> impl ExactSizeIterator<Item = usize> + DoubleEndedIterator;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Array of dimension sizes or strides.

This trait is an abstraction around slices and arrays of usizes. Unlike AsRef<[usize]> this does not require the data to actually be stored in memory. This allows for strides which are computed on-demand or stored in a smaller data type (eg. u32) and expanded to usize.

Required Methods§

Source

fn len(&self) -> usize

Return the length of the array.

Source

fn get(&self, index: usize) -> Option<usize>

Return the index’th entry.

Source

fn iter(&self) -> impl ExactSizeIterator<Item = usize> + DoubleEndedIterator

Return an iterator over the entries.

Provided Methods§

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T: Clone + AsRef<[usize]> + Debug + PartialEq<Self>> SizeArray for T