-
Notifications
You must be signed in to change notification settings - Fork 13k
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 entry_and_modify
#44733
Comments
and_then
on std::collections::hash_map::Entry
and_then
on Entry
APIs
The scope of this has changed to include the |
and_then
on Entry
APIsentry_and_modify
Implement `and_modify` on `Entry` ## Motivation `Entry`s are useful for allowing access to existing values in a map while also allowing default values to be inserted for absent keys. The existing API is similar to that of `Option`, where `or` and `or_with` can be used if the option variant is `None`. The `Entry` API is, however, missing an equivalent of `Option`'s `and_then` method. If it were present it would be possible to modify an existing entry before calling `or_insert` without resorting to matching on the entry variant. Tracking issue: #44733.
Implement `and_modify` on `Entry` ## Motivation `Entry`s are useful for allowing access to existing values in a map while also allowing default values to be inserted for absent keys. The existing API is similar to that of `Option`, where `or` and `or_with` can be used if the option variant is `None`. The `Entry` API is, however, missing an equivalent of `Option`'s `and_then` method. If it were present it would be possible to modify an existing entry before calling `or_insert` without resorting to matching on the entry variant. Tracking issue: rust-lang/rust#44733.
Just wonder, is there any particular reason to keep this feature unstable? I personally find it pretty usable and convenient and it doesn't look like something that can break an unspoken invariant |
@hedgehog1024 The only reason these are kept unstable is because no one pushed for stabilization. Everyone is welcome to submit a PR to stabilize a library feature 😊.
|
@kennytm Does such a PR need to remove the information about this feature from Unstable Book? |
@hedgehog1024 Yes. Those information should be moved into the documentation of the functions. |
@hedgehog1024 Thanks for your support of this feature, much appreciated 😄 |
…-entry_and_modify, r=alexcrichton Stabilize 'entry_and_modify' feature Stabilize `entry_and_modify` feature introduced by rust-lang#44734. Closes rust-lang#44733
I see this feature has been stabilised. I get the following error on rustc 1.25:
|
I think it's due in 1.27 |
Scratch that. I just looked on the stabilisation PR and it's slated for 1.26. Even better! 😁 |
Tracking issue for the
and_modify
method on hash mapEntry
s (added in #44734).The text was updated successfully, but these errors were encountered: