Trait map_in_place::MapVecInPlace [] [src]

pub trait MapVecInPlace<A> {
    fn map<B, F: FnMut(A) -> B>(self, f: F) -> Vec<B>;
    fn map_in_place<B, F: FnMut(A) -> B>(self, f: F) -> Vec<B>;
    fn filter_map<B, F: FnMut(A) -> Option<B>>(self, f: F) -> Vec<B>;
    fn filter_map_in_place<B, F: FnMut(A) -> Option<B>>(self, f: F) -> Vec<B>;
}

Required Methods

Shorter than .into_iter().map(f).collect::<Vec<_>>(), and faster if the types have identical alignment and the size of A is divisible by the size of B: Then the allocation is reused.

This function doesn't attempt to optimize cases where the size of A is a multiple of the size of B: I think capacity is rarely twice or more size, nevermind 3x or 4x.

Reuse the memory owned by self when converting the elements to a different type. For this to be safe the types must have identical alignment and the size of A must be divisible by the size of B (size_of::<A>() % size_of::<B>() == 0).

Panics:

If the conditions above are not met.

Shorter than .into_iter().filter_map(f).collect::<Vec<_>>(), and faster if the types have identical alignment and the size of A is divisible by the size of B: Then the allocation is reused.

This function doesn't (yet) attempt to optimize cases where the size of A is a multiple of the size of B.

Reuse the memory owned by self when filtering and converting the elements to a different type. For this to be safe the types must have identical alignment and the size of A must be divisible by the size of B (`size_of::() % size_of::() == 0).

Panics:

If the conditions above are not met.

Implementors