Closed
Description
Steps
- Implementation in
std
(Add or_insert_with_key to Entry of HashMap/BTreeMap #70996)Merge intostd
Implementation inhashbrown
crate (Add or_insert_with_key to Entry of HashMap hashbrown#152)Merge intohashbrown
Stabilization (Stabilize or_insert_with_key #78083)Make pull request with documentation changes fromChaiTRex/hashbrown
torust-lang/hashbrown
(Imported new documentation for .or_insert_with_key hashbrown#217)Close old issue requesting feature (Add hash_map::Entry.or_insert_with_key() method rfcs#1202)
Metadata
Metadata
Assignees
Labels
Area: `std::collections`Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCLibs issues that are considered "small" or self-containedLibs issues that are tracked on the team's project board.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
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 intostd
as 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
/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
Rollup merge of rust-lang#78083 - ChaiTRex:master, r=m-ou-se
6 remaining items