Tracking Issue for Iterator::collect_into · Issue #94780 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@frengor

Description

@frengor

Feature gate: #![feature(iter_collect_into)]

This is a tracking issue for adding the collect_into method to the Iterator trait.
Iterator::collect_into lets an iterator to be collected into a collection which implements the Extend trait, consuming the iterator and adding every of its item to the collection.
Adding this method has also the benefit of making the Extend trait more discoverable.

Public API

trait Iterator { type Item;

fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
where
    Self: Sized;

}

Steps / History

Unresolved Questions