Trait swiss_army_knife::vec::VecExt
source · [−]pub trait VecExt<T> {
fn try_with_capacity(capacity: usize) -> Result<Vec<T>, AllocError>;
fn new_populated_by_copy(
capacity: usize,
copy: T
) -> Result<Vec<T>, AllocError>
where
T: Copy;
fn new_populated_fallibly<Populator: FnOnce(usize) -> Result<T, AllocError> + Copy>(
capacity: usize,
populator: Populator
) -> Result<Vec<T>, AllocError>;
fn push_unchecked(&mut self, value: T);
}
Expand description
Vec<T>
extension trait.
Required Methods
fn try_with_capacity(capacity: usize) -> Result<Vec<T>, AllocError>
fn try_with_capacity(capacity: usize) -> Result<Vec<T>, AllocError>
Creates a new instance with the given capacity or fails.
fn new_populated_by_copy(capacity: usize, copy: T) -> Result<Vec<T>, AllocError> where
T: Copy,
fn new_populated_by_copy(capacity: usize, copy: T) -> Result<Vec<T>, AllocError> where
T: Copy,
Done this way instead of repeated push()
or specialized extend()
to minimize if
checks for each push()
and give LLVM’s loop unrolling a chance to optimize.
fn new_populated_fallibly<Populator: FnOnce(usize) -> Result<T, AllocError> + Copy>(
capacity: usize,
populator: Populator
) -> Result<Vec<T>, AllocError>
fn new_populated_fallibly<Populator: FnOnce(usize) -> Result<T, AllocError> + Copy>(
capacity: usize,
populator: Populator
) -> Result<Vec<T>, AllocError>
Done this way instead of repeated push()
or specialized extend()
to minimize if
checks for each push()
and give LLVM’s loop unrolling a chance to optimize.
fn push_unchecked(&mut self, value: T)
fn push_unchecked(&mut self, value: T)
Push without checking capacity.