pub trait CollectWithCapacity: Iterator {
// Provided method
fn collect_with_capacity<T>(self, capacity: usize) -> T
where T: ExtendWithCapacity<Self::Item>,
Self: Sized { ... }
}Expand description
Trait for collecting iterator elements into a collection with specified capacity
Provided Methods§
Sourcefn collect_with_capacity<T>(self, capacity: usize) -> T
fn collect_with_capacity<T>(self, capacity: usize) -> T
Collect iterator elements into a collection with pre-allocated capacity.
capacity- Initial capacity to allocate for the collection
T- Collection type that implements ExtendWithCapacity (e.g.,
Vec<X>, String,HashMap<K, V>)
- Collection type that implements ExtendWithCapacity (e.g.,
See also: collect_with()