Skip to content

Implement Default for iterators - #542

Merged
bors merged 1 commit into
rust-lang:masterfrom
clarfonthey:default-iters
Aug 5, 2024
Merged

Implement Default for iterators#542
bors merged 1 commit into
rust-lang:masterfrom
clarfonthey:default-iters

Conversation

@clarfonthey

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@Amanieu

Amanieu commented Aug 5, 2024

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Aug 5, 2024

Copy link
Copy Markdown
Contributor

📌 Commit abd706e has been approved by Amanieu

It is now in the queue for this repository.

@bors

bors commented Aug 5, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit abd706e with merge f677701...

@bors

bors commented Aug 5, 2024

Copy link
Copy Markdown
Contributor

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

@bors
bors merged commit f677701 into rust-lang:master Aug 5, 2024
@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