pub struct ChunkedVecSized<T, const N: usize>(/* private fields */);Expand description
A marker type used for compile-time chunk size validation.
This type is used internally to ensure that chunk sizes are valid at compile time.
Implementations§
Source§impl<T, const N: usize> ChunkedVecSized<T, N>
Implementation of creation methods for ChunkedVec with fixed chunk size.
impl<T, const N: usize> ChunkedVecSized<T, N>
Implementation of creation methods for ChunkedVec with fixed chunk size.
This implementation provides methods to create ChunkedVec instances with a compile-time fixed chunk size.
The chunk size is specified through the type parameter N and cannot be changed after creation.
Sourcepub fn new() -> ChunkedVec<T, N>
pub fn new() -> ChunkedVec<T, N>
Creates a new empty ChunkedVec with a fixed chunk size of N.
The chunk size N determines how many elements are stored in each internal chunk.
This size is fixed at compile-time and provides optimal performance for scenarios
where the chunk size is known in advance.
§Examples
use chunked_vec::{ChunkedVecSized, ChunkedVec};
let vec: ChunkedVec<i32, 8> = ChunkedVecSized::new();Sourcepub fn with_capacity(capacity: usize) -> ChunkedVec<T, N>
pub fn with_capacity(capacity: usize) -> ChunkedVec<T, N>
Creates an empty ChunkedVec with a fixed chunk size of N and the specified capacity.
The actual number of chunks allocated will be calculated as ceiling(capacity / N), where N is the fixed chunk size. This method is useful when you know the approximate number of elements you’ll be storing and want to avoid reallocations.
§Arguments
capacity- The minimum number of elements the ChunkedVec should be able to hold
§Examples
use chunked_vec::{ChunkedVecSized, ChunkedVec};
let vec: ChunkedVec<i32, 8> = ChunkedVecSized::with_capacity(10);
// This will allocate 2 chunks (ceiling(10/8) = 2) with total capacity of 16Sourcepub fn with_chunk_count(chunk_count: usize) -> ChunkedVec<T, N>
pub fn with_chunk_count(chunk_count: usize) -> ChunkedVec<T, N>
Creates an empty ChunkedVec with a fixed chunk size of N and pre-allocates
the specified number of chunks.
This method provides direct control over the number of chunks to allocate, which can be more intuitive than specifying capacity when working with chunked storage.
§Arguments
chunk_count- The number of chunks to pre-allocate
§Examples
use chunked_vec::{ChunkedVecSized, ChunkedVec};
let vec: ChunkedVec<i32, 8> = ChunkedVecSized::with_chunk_count(2);
// This will allocate 2 chunks with total capacity of 16