Type Definition coca::collections::AllocVec
source · [−]pub type AllocVec<T, I = usize> = Vec<T, AllocStorage<ArrayLayout<T>>, I>;
This is supported on crate feature
alloc
only.Expand description
A vector using a heap-allocated slice for storage.
Note this still has a fixed capacity, and will never reallocate.
Examples
let mut vec = coca::collections::AllocVec::<char>::with_capacity(3);
vec.push('a');
vec.push('b');
vec.push('c');
assert!(vec.try_push('d').is_err());
Implementations
sourceimpl<T: Copy, I: Capacity> AllocVec<T, I>
impl<T: Copy, I: Capacity> AllocVec<T, I>
sourcepub fn with_capacity(capacity: I) -> Self
pub fn with_capacity(capacity: I) -> Self
Constructs a new, empty AllocVec<T, I>
with the specified capacity.
Panics
Panics if the specified capacity cannot be represented by a usize
.