ArrayWithSize

Trait ArrayWithSize 

Source
pub trait ArrayWithSize<T, const N: usize>: Array<T, N> {
    type WithSize<const M: usize>: ArrayWithSize<T, M>;

    // Provided methods
    fn resize<const M: usize>(self) -> Self::WithSize<M>
       where T: Default { ... }
    fn resize_with_value<const M: usize>(self, value: T) -> Self::WithSize<M>
       where T: Clone { ... }
}
Expand description

An type equivalent to an array with a generic size that can be changed

ex, [T;N] is an array with a generic size, but struct RGBA([T;4]) don’t have a generic size (always 4 components)

Required Associated Types§

Source

type WithSize<const M: usize>: ArrayWithSize<T, M>

Provided Methods§

Source

fn resize<const M: usize>(self) -> Self::WithSize<M>
where T: Default,

Resize the array to the given size, filling non existing component with Default Fill non existing component with Default

Source

fn resize_with_value<const M: usize>(self, value: T) -> Self::WithSize<M>
where T: Clone,

Fill non existing component with the Cloned given value

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<T, const N: usize> ArrayWithSize<T, N> for [T; N]

Source§

type WithSize<const M: usize> = [T; M]

Implementors§