Trait StaticOwnedChunks

Source
pub trait StaticOwnedChunks: Sized {
    type Iter<const CHUNK_SZ: usize>;

    // Required method
    fn static_owned_chunks<const CHUNK_SZ: usize>(self) -> Self::Iter<CHUNK_SZ>;
}
Expand description

A variant of OwnedChunks with const chunk size; this primarily exists to allow storage size optimizations for types where storage size depends on a constant, like arrays. For further information see the docs of array::ArrayChunks.

§Example

use owned_chunks::StaticOwnedChunks;

fn take_ownership(v: Vec<i32>) {
    // some implementation
}

for chunk in [vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]].static_owned_chunks::<2>() {
    for v in chunk {
        take_ownership(v);
    }
}

Required Associated Types§

Source

type Iter<const CHUNK_SZ: usize>

Required Methods§

Source

fn static_owned_chunks<const CHUNK_SZ: usize>(self) -> Self::Iter<CHUNK_SZ>

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> StaticOwnedChunks for [T; N]

Source§

type Iter<const CHUNK_SZ: usize> = ArrayChunks<T, N, CHUNK_SZ>

Source§

fn static_owned_chunks<const CHUNK_SZ: usize>(self) -> Self::Iter<CHUNK_SZ>

Implementors§