pub trait Reserve: Default {
    // Provided method
    fn reserve(_: usize) -> Self { ... }
}
Expand description

Create a data structure and reserve some amount of space for it to grow into

Examples

  • Vec is Reserve, and invokes Vec::with_capacity
  • tinyvec::ArrayVec is Reserve and invokes Default::default() because creating an ArrayVec automatically allocates the required space on the stack.

Provided Methods§

source

fn reserve(_: usize) -> Self

Create an instance of the collection with a given capacity.

Used to reserve some contiguous space, e.g. Vec::with_capacity

The default implementation invokes Default::default

Implementations on Foreign Types§

source§

impl<K, V> Reserve for BTreeMap<K, V>

source§

impl<A: Array> Reserve for ArrayVec<A>

source§

impl<K: Eq + Hash, V> Reserve for HashMap<K, V>

source§

fn reserve(n: usize) -> Self

source§

impl<T> Reserve for Vec<T>

source§

fn reserve(n: usize) -> Self

Implementors§