Struct fixed_capacity_vec::FixedCapacityVec
source · pub struct FixedCapacityVec<T, const N: usize> { /* private fields */ }
Expand description
Like Vec
with a capacity fixed at compile time
When full, can be converted without copying into Box<[T; N]>
, using TryFrom
.
Comparison with related data types
All of the following types store only the actual buffer on the heap, and they are interconvertible without copying the data.
Type | Size and representation (as eg on stack) | Full? | Mutability |
---|---|---|---|
Vec | 3 words: pointer, length, capacity | maybe | indefinitely appendable |
Box<[T]> | 2 words: pointer, length = capacity | always | length fixed at runtime |
FixedCapacityVec<[T; N]> | 2 words: pointer, length | maybe | appendable, but capacity fixed at compile time |
Box<[T; N]> | 1 word: pointer | always | length fixed at compile time |
Implementations§
Trait Implementations§
source§impl<T, const N: usize> Drop for FixedCapacityVec<T, N>
impl<T, const N: usize> Drop for FixedCapacityVec<T, N>
source§impl<T, const N: usize> TryFrom<FixedCapacityVec<T, N>> for Box<[T; N]>
impl<T, const N: usize> TryFrom<FixedCapacityVec<T, N>> for Box<[T; N]>
Convert a full FixedCapacityVec
into a boxed array.
If the FixedCapacityVec
isn’t full, it is returned as the Err
§type Error = FixedCapacityVec<T, N>
type Error = FixedCapacityVec<T, N>
The type returned in the event of a conversion error.
source§fn try_from(
fcvec: FixedCapacityVec<T, N>
) -> Result<Box<[T; N]>, FixedCapacityVec<T, N>>
fn try_from( fcvec: FixedCapacityVec<T, N> ) -> Result<Box<[T; N]>, FixedCapacityVec<T, N>>
Performs the conversion.
impl<T: RefUnwindSafe, const N: usize> RefUnwindSafe for FixedCapacityVec<T, N>
impl<T: Send, const N: usize> Send for FixedCapacityVec<T, N>
impl<T: Sync, const N: usize> Sync for FixedCapacityVec<T, N>
impl<T: UnwindSafe, const N: usize> UnwindSafe for FixedCapacityVec<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Unpin for FixedCapacityVec<T, N>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more