Trait webrender::util::VecHelper

source ·
pub trait VecHelper<T> {
    // Required methods
    fn alloc(&mut self) -> Allocation<'_, T>;
    fn entry(&mut self, index: usize) -> VecEntry<'_, T>;
    fn take(&mut self) -> Self;
    fn cleared(self) -> Self;
    fn take_and_preallocate(&mut self) -> Self;
}

Required Methods§

source

fn alloc(&mut self) -> Allocation<'_, T>

Growns the vector by a single entry, returning the allocation.

source

fn entry(&mut self, index: usize) -> VecEntry<'_, T>

Either returns an existing elemenet, or grows the vector by one. Doesn’t expect indices to be higher than the current length.

source

fn take(&mut self) -> Self

Equivalent to mem::replace(&mut vec, Vec::new())

source

fn cleared(self) -> Self

Call clear and return self (useful for chaining with calls that move the vector).

source

fn take_and_preallocate(&mut self) -> Self

Functionally equivalent to mem::replace(&mut vec, Vec::new()) but tries to keep the allocation in the caller if it is empty or replace it with a pre-allocated vector.

Implementations on Foreign Types§

source§

impl<T> VecHelper<T> for Vec<T>

source§

fn alloc(&mut self) -> Allocation<'_, T>

source§

fn entry(&mut self, index: usize) -> VecEntry<'_, T>

source§

fn take(&mut self) -> Self

source§

fn cleared(self) -> Self

source§

fn take_and_preallocate(&mut self) -> Self

Implementors§