Tracking Issue for Iterator::collect_into
· Issue #94780 · rust-lang/rust (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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
- Implementation: Add Iterator::collect_into #93057
- Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- Is it worth it to have this API? The
Iterator
interface is already pretty large, and use cases can easily be written differently without this API.