Trait swiss_army_knife::vec::VecExt [−][src]
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>; }
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.
Implementations on Foreign Types
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>