Trait recycle_vec::VecExt

source ·
pub trait VecExt<T> {
    // Required method
    fn recycle<U>(self) -> Vec<U>;
}
Expand description

A trait that provides an API for recycling Vec’s internal buffers

Required Methods§

source

fn recycle<U>(self) -> Vec<U>

Allows re-interpreting the type of a Vec to reuse the allocation. The vector is emptied and any values contained in it will be dropped. The target type must have the same size and alignment as the source type. This API doesn’t transmute any values of T to U, because it makes sure to empty the vector before any unsafe operations.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> VecExt<T> for Vec<T>

source§

fn recycle<U>(self) -> Vec<U>

Implementors§