-
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 implementation of Extend for () #50234
Conversation
r? @Kimundi (rust_highfive has picked a reviewer for you, use r? to override) |
Ping from triage @Kimundi! This PR needs your review. |
@rfcbot fcp merge |
@rust-lang/libs Please summon rfcbot again, thanks. |
@rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Could you show an example? |
@withoutboats The specific case where I hit this was wanting to |
src/libcore/iter/traits.rs
Outdated
#[stable(feature = "extend_for_unit", since = "1.27.0")] | ||
impl Extend<()> for () { | ||
fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T) { | ||
for _ in iter {} |
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 believe iter.for_each(drop)
can be faster for some iterators like chain.
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.
Huh, interesting.
This comment has been minimized.
This comment has been minimized.
🔔 This is now entering its final comment period, as per the review above. 🔔 |
src/libcore/iter/traits.rs
Outdated
@@ -352,6 +352,13 @@ pub trait Extend<A> { | |||
fn extend<T: IntoIterator<Item=A>>(&mut self, iter: T); | |||
} | |||
|
|||
#[stable(feature = "extend_for_unit", since = "1.27.0")] |
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.
This should become 1.28.0.
The final comment period, with a disposition to merge, as per the review above, is now complete. |
@bors: r+ |
📌 Commit 5028b9c has been approved by |
@bors: r- er oops, mind updating the stability attribute? |
Also while you're at it, mind adding a small test? |
@bors r=alexcrichton rollup |
📌 Commit a74e168 has been approved by |
Add implementation of Extend for () This is useful in some generic code which wants to collect iterators of items into a result.
☀️ Test successful - status-appveyor, status-travis |
683: impl ParallelExtend<()> for () r=cuviper a=cuviper Mirrors rust-lang/rust#50234 Co-authored-by: Josh Stone <cuviper@gmail.com>
This is useful in some generic code which wants to collect iterators of items into a result.