You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking Issue for or_insert_with_key feature #71024
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.
Activity
jonas-schievink commentedon Apr 11, 2020
That seems like the wrong PR
ChaiTRex commentedon Apr 11, 2020
@jonas-schievink Thank you. Corrected.
Also, added a 2015 issue that requested this feature so that it can be closed if this is accepted.
ChaiTRex commentedon Apr 12, 2020
Merged into
hashbrown(rust-lang/hashbrown#152) and intostdas unstable (#70996).a1phyr commentedon Oct 17, 2020
What does this feature need to be stabilized ?
ChaiTRex commentedon Oct 19, 2020
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/BTreeMapentry 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
Rollup merge of rust-lang#78083 - ChaiTRex:master, r=m-ou-se
Rollup merge of rust-lang#78083 - ChaiTRex:master, r=m-ou-se
jplatte commentedon Dec 21, 2020
Stabilized, this tracking issue can be closed AFAICT 🙂
ChaiTRex commentedon Feb 11, 2021
Note: Fully stabilized today in Rust 1.50 in
HashMapand inBTreeMap.Rollup merge of #78083 - ChaiTRex:master, r=m-ou-se