Skip to content
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

Implement Default for iterators #542

Merged
merged 1 commit into from
Aug 5, 2024
Merged

Conversation

clarfonthey
Copy link
Contributor

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.

@JustForFun88
Copy link
Contributor

As far as I remember, parallel iterator (rayon) uses RawIterRange directly, so maybe it would be nice to implement Default for RawIterRange too.

@clarfonthey
Copy link
Contributor Author

That would be a bit difficult for a pub(crate) iterator.

@Amanieu
Copy link
Member

Amanieu commented Aug 5, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Aug 5, 2024

📌 Commit abd706e has been approved by Amanieu

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 5, 2024

⌛ Testing commit abd706e with merge f677701...

@bors
Copy link
Contributor

bors commented Aug 5, 2024

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing f677701 to master...

@bors bors merged commit f677701 into rust-lang:master Aug 5, 2024
24 checks passed
@clarfonthey clarfonthey deleted the default-iters branch August 5, 2024 21:48
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`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 4, 2024
impl `Default` for `HashMap`/`HashSet` iterators that don't already have it

This is a follow-up to #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 #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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants