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

Tracking Issue for or_insert_with_key feature #71024

Closed
7 tasks done
ChaiTRex opened this issue Apr 11, 2020 · 7 comments
Closed
7 tasks done

Tracking Issue for or_insert_with_key feature #71024

ChaiTRex opened this issue Apr 11, 2020 · 7 comments
Labels
A-collections Area: `std::collection` B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Small Libs issues that are considered "small" or self-contained Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ChaiTRex
Copy link
Contributor

ChaiTRex commented Apr 11, 2020

Steps

@ChaiTRex ChaiTRex added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Apr 11, 2020
@jonas-schievink
Copy link
Contributor

* Implementation in `std` (#70966)

That seems like the wrong PR

@ChaiTRex
Copy link
Contributor Author

@jonas-schievink Thank you. Corrected.

Also, added a 2015 issue that requested this feature so that it can be closed if this is accepted.

@jonas-schievink jonas-schievink added A-collections Area: `std::collection` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 11, 2020
@ChaiTRex
Copy link
Contributor Author

Merged into hashbrown (rust-lang/hashbrown#152) and into std as unstable (#70996).

@jonas-schievink jonas-schievink added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Apr 12, 2020
@KodrAus KodrAus added I-nominated Libs-Small Libs issues that are considered "small" or self-contained Libs-Tracked Libs issues that are tracked on the team's project board. labels Jul 29, 2020
@a1phyr
Copy link
Contributor

a1phyr commented Oct 17, 2020

What does this feature need to be stabilized ?

@ChaiTRex
Copy link
Contributor Author

This is my first stabilization report, so please let me know if it's insufficient.

Stabilization report

Summary

This allows inserting key-derived values when a HashMap/BTreeMap entry is vacant.

The difference between this and .or_insert_with(|| ... ) is that this provides a reference to the key to the closure after it is moved with .entry(key_being_moved), avoiding the need to copy or clone the key.

Examples

Edge cases

I cannot think of any edge cases.

Stabilization pull request

The stabilization pull request is #78083

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Dec 19, 2020
Stabilize or_insert_with_key

Stabilizes the `or_insert_with_key` feature from rust-lang#71024. This allows inserting key-derived values when a `HashMap`/`BTreeMap` entry is vacant.

The difference between this and  `.or_insert_with(|| ... )` is that this provides a reference to the key to the closure after it is moved with `.entry(key_being_moved)`, avoiding the need to copy or clone the key.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Dec 19, 2020
Stabilize or_insert_with_key

Stabilizes the `or_insert_with_key` feature from rust-lang#71024. This allows inserting key-derived values when a `HashMap`/`BTreeMap` entry is vacant.

The difference between this and  `.or_insert_with(|| ... )` is that this provides a reference to the key to the closure after it is moved with `.entry(key_being_moved)`, avoiding the need to copy or clone the key.
@jplatte
Copy link
Contributor

jplatte commented Dec 21, 2020

Stabilized, this tracking issue can be closed AFAICT 🙂

@ChaiTRex
Copy link
Contributor Author

Note: Fully stabilized today in Rust 1.50 in HashMap and in BTreeMap.

eggyal pushed a commit to eggyal/copse that referenced this issue Jan 9, 2023
Stabilize or_insert_with_key

Stabilizes the `or_insert_with_key` feature from rust-lang/rust#71024. This allows inserting key-derived values when a `HashMap`/`BTreeMap` entry is vacant.

The difference between this and  `.or_insert_with(|| ... )` is that this provides a reference to the key to the closure after it is moved with `.entry(key_being_moved)`, avoiding the need to copy or clone the key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: `std::collection` B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Small Libs issues that are considered "small" or self-contained Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants