Trait CollectWithCapacity

Source
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§

Source

fn collect_with_capacity<T>(self, capacity: usize) -> T
where T: ExtendWithCapacity<Self::Item>, Self: Sized,

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>)

See also: collect_with()

Implementors§