Crate owned_chunks
source · [−]Expand description
A collection of iterators and traits that allow you to get owned chunks
from collections (currently Vec
and array
)
Example
use owned_chunks::OwnedChunks;
fn take_ownership(v: Vec<i32>) {
// implementation
}
for (ix, chunk) in vec![vec![1, 2], vec![3, 4], vec![5, 6]].owned_chunks(2).enumerate() {
match ix {
0 => assert_eq!(&[vec![1, 2], vec![3, 4]], chunk.as_slice()),
1 => assert_eq!(&[vec![5, 6]], chunk.as_slice()),
_ => panic!("no more chunks expected"),
}
for vec in chunk {
take_ownership(vec);
}
}
Modules
Traits
A trait to get owned chunks from a collection.
This is very similar to the slice::*chunks*
family of functions except that the chunks will
not be references/slices into the storage but iterators that yield the owned items inside it.
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
.