Trait len_trait::capacity::Capacity
[−]
[src]
pub trait Capacity: Len { fn capacity(&self) -> usize; }
A trait for describing the capacity of a collection.
Because frequently allocating memory can be inefficient, collections often store room for more data than they actually hold. This "extra length" is represented by capacity, stating the maximum length that can be occupied without any memory allocations.
Obtaining the capacity of the collection must take a constant amount of time and space.
Required Methods
fn capacity(&self) -> usize
Returns the capacity of the collection.
If this collection stores zero-sized types, then it effectively has infinite capacity. For
this reason, those collections should have a capacity of usize::MAX
.
Implementors
impl<T: Ord> Capacity for BinaryHeap<T>
impl Capacity for String
impl<T> Capacity for Vec<T>
impl<T> Capacity for VecDeque<T>