Closed
Description
The various Entry APIs (e.g., hash_map::Entry
, btree_map::Entry
) currently have or_insert
, and or_insert_with
. However, when V: Default
, I believe they should also have an or_default
. This would make it nicer to work with things like maps of maps, maps of lists, etc. While it's true that this is equivalent to or_insert_with(Default::default)
, I would argue that or_default
is much more readable.
I'd be happy to take a stab at implementing this, but wanted to air the idea first.
Metadata
Metadata
Assignees
Labels
Area: `std::collections`Blocker: Implemented in the nightly compiler and unstable.Category: An issue proposing an enhancement or a PR with one.Relevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
steveklabnik commentedon Sep 5, 2017
Generally, the way the libs team works is "open a PR if a change is small, open an RFC if a change is big." I'm not on the libs team, but this feels pretty small to me; you already almost have an implementation in the comment!
jonhoo commentedon Sep 5, 2017
@steveklabnik PR submitted!
Auto merge of #44344 - jonhoo:entry_or_default, r=BurntSushi
dtolnay commentedon Nov 15, 2017
An unstable
or_default()
method was added in #44344. This issue is now the tracking issue for stabilization.khuey commentedon Feb 20, 2018
Is there any reason not to just stabilize this?
SimonSapin commentedon Mar 17, 2018
In Nightly for 6 months, looks good to me to stabilize.
@rfcbot fcp merge
rfcbot commentedon Mar 17, 2018
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
rfcbot commentedon Mar 19, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Mar 29, 2018
The final comment period is now complete.
Auto merge of #51079 - GuillaumeGomez:stabilize-entry-or-default, r=S…