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
VecisReserve, and invokesVec::with_capacitytinyvec::ArrayVecisReserveand invokesDefault::default()because creating anArrayVecautomatically allocates the required space on the stack.
Provided Methods§
Sourcefn reserve(_: usize) -> Self
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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl<A: Array> Reserve for ArrayVec<A>
impl<K, V> Reserve for BTreeMap<K, V>
Available on crate feature
alloc only.