ChunkedVecSized

Struct ChunkedVecSized 

Source
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.

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.

Source

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();
Source

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 16
Source

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

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for ChunkedVecSized<T, N>

§

impl<T, const N: usize> RefUnwindSafe for ChunkedVecSized<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for ChunkedVecSized<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for ChunkedVecSized<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for ChunkedVecSized<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for ChunkedVecSized<T, N>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.