-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Iterator::collect_into #93057
Add Iterator::collect_into #93057
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've skimmed the previous discussions in #48597 and #92982 and I don't personally see the appeal of this. Adding a minor variation like this to accomplish something that is already easy distracts people into having to think about which way to write the same thing when, rather than just writing what they mean, and that overshadows any benefit of having the API.
Is there someone else from @rust-lang/libs-api who would prefer to see this signature added?
fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
If so, I'll let you approve the unstable and we can hash it out further when it comes to stabilization.
I'm not entirely convinced, but I do see how it makes (I don't think Some relevant grep counts from the crates on crates.io:
(That particular implementation would be more powerful if we had |
I personally don't think Moreover, as pointed out by @m-ou-se, when learning about iterators, Finally, I think people will just use the method they prefer. Also note that the proposed doc is clearly stating that
|
☔ The latest upstream changes (presumably #93645) made this pull request unmergeable. Please resolve the merge conflicts. |
0b978ef
to
64b86bb
Compare
This comment has been minimized.
This comment has been minimized.
64b86bb
to
70d8449
Compare
☔ The latest upstream changes (presumably #94103) made this pull request unmergeable. Please resolve the merge conflicts. |
70d8449
to
b9a44b1
Compare
This comment has been minimized.
This comment has been minimized.
b9a44b1
to
04b3162
Compare
Alright, let's try this out as an unstable feature. Can you open a tracking issue and put its number it in the |
Of course, give me a moment. |
@bors r+ |
📌 Commit 63eddb3 has been approved by |
Add Iterator::collect_into This PR adds `Iterator::collect_into` as proposed by `@cormacrelf` in rust-lang#48597 (see rust-lang#48597 (comment)). Followup of rust-lang#92982. This adds the following method to the Iterator trait: ```rust fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E ```
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#91804 (Make some `Clone` impls `const`) - rust-lang#92541 (Mention intent of `From` trait in its docs) - rust-lang#93057 (Add Iterator::collect_into) - rust-lang#94739 (Suggest `if let`/`let_else` for refutable pat in `let`) - rust-lang#94754 (Warn users about `||` in let chain expressions) - rust-lang#94763 (Add documentation about lifetimes to thread::scope.) - rust-lang#94768 (Ignore `close_read_wakes_up` test on SGX platform) - rust-lang#94772 (Add miri to the well known conditional compilation names and values) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Awesome, thanks everyone, especially @frengor, IIRC first contribution and did a great job. 🦀 |
Thank you! |
This PR adds
Iterator::collect_into
as proposed by @cormacrelf in #48597 (see #48597 (comment)).Followup of #92982.
This adds the following method to the Iterator trait: