Skip to content

Add get_each_mut methods on RawTable and HashMap #239

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 1 commit into from
Feb 17, 2021

Conversation

cole-miller
Copy link

This PR adds a new method get_each_mut on RawTable and new methods get_each_mut and get_each_key_value_mut on HashTable. These methods enable looking up mutable references to several table or map entries at once. They take advantage of min_const_generics, which is available without a feature gate on recent nightly (but not stable) compilers. Hence everything is behind #[cfg(feature = "nightly")] for now.

Closes #151 (cc @HeroicKatora).

@cole-miller cole-miller force-pushed the get-each-mut branch 4 times, most recently from 46b0f64 to 14d53af Compare February 15, 2021 23:29
@cole-miller cole-miller marked this pull request as ready for review February 16, 2021 00:25
@cole-miller
Copy link
Author

Okay, fixed the problems I could find on my own, so this should be ready for review.

Copy link
Member

@Amanieu Amanieu left a comment

Choose a reason for hiding this comment

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

Great work! I think this is probably one of the most awaited features on HashMap!

These methods enable looking up mutable references to several entries in
a table or map at once. They make use of the min_const_generics feature,
which is available without a feature gate on recent nightly — but not
yet stable — rustc. Hence everything added here is behind `#[cfg(feature
= "nightly")]`.

This also removes an unnecessary `unsafe` annotation for
`Bucket::as_ptr`.
@Amanieu
Copy link
Member

Amanieu commented Feb 17, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Feb 17, 2021

📌 Commit afce097 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Feb 17, 2021

⌛ Testing commit afce097 with merge de77272...

@bors
Copy link
Contributor

bors commented Feb 17, 2021

☀️ Test successful - checks-travis
Approved by: Amanieu
Pushing de77272 to master...

@bors bors merged commit de77272 into rust-lang:master Feb 17, 2021
@cole-miller
Copy link
Author

Thanks!

This was referenced Mar 15, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Features request: Mutably lookup multiple distinct values
3 participants