Skip to main content

ContainerReserve

Trait ContainerReserve 

Source
pub trait ContainerReserve {
    // Required method
    fn reserve(&mut self, additional: usize);
}
Expand description

A trait to reserve space in a container, in case you know how many values are about to enter and can avoid reallocations by reserving more space at once.

Required Methods§

Source

fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the cache. The collection may reserve more space to avoid frequent reallocations.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<I, O, S> ContainerReserve for HashMap<I, O, S>
where I: Eq + Hash, S: BuildHasher,

Source§

fn reserve(&mut self, additional: usize)

Implementors§