Skip to content

impl Default for collection iterators that don't already have it #128261

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

clarfonthey
Copy link
Contributor

There is a pretty strong precedent for implementing Default for collection iterators, and this does so for some where this implementation was missed.

I don't think this needs a separate ACP (since this precedent already exists, and these feel like they were just missed), however, it will need an FCP since these implementations are instantly stable.

@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2024

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 27, 2024
@rust-log-analyzer

This comment has been minimized.

@Amanieu Amanieu added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 28, 2024
@Amanieu
Copy link
Member

Amanieu commented Jul 28, 2024

This implements Default for:

  • VecDeque's Iter and IterMut
  • BTreeMap's RangeMut and ValuesMut
  • BinaryHeap's Iter

These are trait impls and therefore instantly stable.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jul 28, 2024

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jul 28, 2024
@rfcbot
Copy link
Collaborator

rfcbot commented Jul 28, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

bors added a commit to rust-lang/hashbrown that referenced this pull request Aug 5, 2024
Implement Default for iterators

See rust-lang/rust#128261 for a similar PR for some libstd iterators. In order to do a similar PR for the `HashSet` and `HashMap` types, we need to make these changes to `hashbrown` first to actually implement them.

One small caveat is that I chose to only implement `Default` for `RawIter` and not `RawIterRange`, since it really exists as an implementation detail anyway, and the best implementation would involve just using the `RawIter` implementation anyway.
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Aug 7, 2024
@rfcbot
Copy link
Collaborator

rfcbot commented Aug 7, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Aug 7, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 7, 2024

📌 Commit 0b99720 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 7, 2024
@dtolnay dtolnay self-assigned this Aug 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 7, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#128221 (Add implied target features to target_feature attribute)
 - rust-lang#128261 (impl `Default` for collection iterators that don't already have it)
 - rust-lang#128353 (Change generate-copyright to generate HTML, with cargo dependencies included)
 - rust-lang#128679 (codegen: better centralize function declaration attribute computation)
 - rust-lang#128732 (make `import.vis` is immutable)
 - rust-lang#128755 (Integrate crlf directly into related test file instead via of .gitattributes)
 - rust-lang#128772 (rustc_codegen_ssa: Set architecture for object crate for 32-bit SPARC)
 - rust-lang#128782 (unused_parens: do not lint against parens around &raw)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2ee9678 into rust-lang:master Aug 7, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 7, 2024
Rollup merge of rust-lang#128261 - clarfonthey:iter-default, r=dtolnay

impl `Default` for collection iterators that don't already have it

There is a pretty strong precedent for implementing `Default` for collection iterators, and this does so for some where this implementation was missed.

I don't think this needs a separate ACP (since this precedent already exists, and these feel like they were just missed), however, it *will* need an FCP since these implementations are instantly stable.
@clarfonthey clarfonthey deleted the iter-default branch August 7, 2024 23:17
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Aug 15, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 3, 2024
…olnay

impl `Default` for `HashMap`/`HashSet` iterators that don't already have it

This is a follow-up to rust-lang#128261 that isn't included in that PR because it depends on:

* [x] rust-lang/hashbrown#542 (`Default`)
* [x] `hashbrown` release containing above

It also wasn't included in rust-lang#128261 initially and should have its own FCP, since these are also insta-stable.

Changes added:

* `Default for hash_map::{Iter, IterMut, IntoIter, IntoKeys, IntoValues, Keys, Values, ValuesMut}`
* `Default for hash_set::{Iter, IntoIter}`

Changes that were added before FCP, but are being deferred to later:

* `Clone for hash_map::{IntoIter, IntoKeys, IntoValues} where K: Clone, V: Clone`
* `Clone for hash_set::IntoIter where K: Clone`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants