-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[RFC] Entry API v3: replace Entry::get with Entry::default and Entry::default_with #22930
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
d7782ad
to
009f861
Compare
reason = "matches entry v3 specification, waiting for dust to settle")] | ||
/// Ensures a value is in the entry by inserting the default if empty, and returns | ||
/// a mutable reference to the value in the entry. | ||
pub fn default(self. default: V) -> &'a mut V { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/self./self,
RFC posted: rust-lang/rfcs#921 All imports/typos/missed-things fixed. |
☔ The latest upstream changes (presumably #23107) made this pull request unmergeable. Please resolve the merge conflicts. |
Note: the RFC has now been merged (with updated names) |
c9b5258
to
0c4a120
Compare
Rebased with updated names. r? @aturon |
(added I'd also be fine insta-stabilizing these methods as they've been around for quite some time and we're just tweaking the naming here basically. |
I'm not comfortable stabilizing these quite yet. We could go one step further and just make these methods on the Map itself, for instance. I also see no particular urgency to stabilize them; they are pure convenience (though very convenient indeed). |
Oh whoops I forgot to actually, you know, test the rebase/fix. Tidy error fixed; building now. |
This is really, really nice! You've done great work with I also agree that there's no rush to stabilize these new methods, which are more than a rename. |
r=me once tests are looking good locally |
looks good locally (had to make one update) |
@@ -1126,6 +1126,8 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> { | |||
impl<'a, K: Ord, V> Entry<'a, K, V> { | |||
#[unstable(feature = "collections", | |||
reason = "matches collection reform v2 specification, waiting for dust to settle")] | |||
#[deprecated(since = "1.0", | |||
reason = "replaced with more ergonomic `default` and `default_with`")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or_insert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
(r=me after nits) |
☔ The latest upstream changes (presumably #23593) made this pull request unmergeable. Please resolve the merge conflicts. |
Given the proximity to beta, I'm thinking we should probably go ahead and mark these Worst case, if we do find a problem, we can revise before 1.0. |
I'd really like to let this sit if possible. Although empirically it seems like we've played very fast and loose with stable vs unstable so far. Is it possible to stabilize things in the beta -> stable transition? There's still (in my mind) open questions about whether this functionality should just be on the map directly. Although I suppose we can deprecate this in favour of that quite easily. |
@gankro I'm happy to defer to your judgment here. In terms of ongoing stabilization: we will be adding unstable APIs, and stabilizing existing ones, continuously. It is likely possible to stabilize a few APIs during the 1.0 beta and have those available at 1.0, but it's not entirely clear yet. In terms of "fast and loose", I'm not sure exactly what you're referring to -- perhaps just that we've been willing to change |
Easy to stabilize later; let's land this unstable for now. Can review in coming weeks, perhaps with removal of deprecated API. |
@bors r=aturon |
📌 Commit d3d11b2 has been approved by |
☔ The latest upstream changes (presumably #23654) made this pull request unmergeable. Please resolve the merge conflicts. |
Ugh what another rebase? |
@bors r=aturon |
📌 Commit 1132198 has been approved by |
RFC pending, but this is the patch that does it. Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples. Closes #23508
💔 Test failed - auto-linux-64-x-android-t |
@bors r=aturon |
📌 Commit 1b98f6d has been approved by |
RFC pending, but this is the patch that does it. Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples. Closes #23508
RFC pending, but this is the patch that does it.
Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples.
Closes #23508