Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tracking issue for entry_and_modify #44733

Closed
mchlrhw opened this issue Sep 21, 2017 · 9 comments
Closed

Tracking issue for entry_and_modify #44733

mchlrhw opened this issue Sep 21, 2017 · 9 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@mchlrhw
Copy link
Contributor

mchlrhw commented Sep 21, 2017

Tracking issue for the and_modify method on hash map Entrys (added in #44734).

@mchlrhw mchlrhw changed the title Tracking issue for and_then on std::collections::hash_map::Entry Tracking issue for and_then on Entry APIs Sep 21, 2017
@mchlrhw
Copy link
Contributor Author

mchlrhw commented Sep 21, 2017

The scope of this has changed to include the BTreeMap as well as HashMap on the advice of @kennytm.

@aidanhs aidanhs added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Sep 21, 2017
@mchlrhw mchlrhw changed the title Tracking issue for and_then on Entry APIs Tracking issue for entry_and_modify Sep 26, 2017
bors added a commit that referenced this issue Oct 6, 2017
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.
cuviper pushed a commit to rayon-rs/rayon-hash that referenced this issue Nov 14, 2017
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.
@hedgehog1024
Copy link
Contributor

hedgehog1024 commented Jan 17, 2018

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

@kennytm
Copy link
Member

kennytm commented Jan 17, 2018

@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 😊.

  1. Ensure the documentations, examples and implementations are correct. Ensure no missing edge cases. Ensure necessary tests are present.
  2. Change all #[unstable] attributes related to that feature to #[stable].
  3. Submit the PR.
  4. Wait for team consensus.
  5. Profit!

@kennytm kennytm added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jan 17, 2018
@hedgehog1024
Copy link
Contributor

@kennytm Does such a PR need to remove the information about this feature from Unstable Book?

@kennytm
Copy link
Member

kennytm commented Jan 17, 2018

@hedgehog1024 Yes. Those information should be moved into the documentation of the functions.

@mchlrhw
Copy link
Contributor Author

mchlrhw commented Jan 18, 2018

@hedgehog1024 Thanks for your support of this feature, much appreciated 😄

kennytm added a commit to kennytm/rust that referenced this issue Feb 25, 2018
…-entry_and_modify, r=alexcrichton

Stabilize 'entry_and_modify' feature

Stabilize `entry_and_modify` feature introduced by rust-lang#44734.

Closes rust-lang#44733
@Jarngreipr
Copy link

I see this feature has been stabilised.
Should it now be available for use on stable?

I get the following error on rustc 1.25:

error[E0658]: use of unstable library feature 'entry_and_modify' (see issue #44733)
   --> src/models/mod.rs:155:34
    |
155 |                                 .and_modify(|&mut tup| {tup.1 = idx}) ;
    |                                  ^^^^^^^^^^

@mchlrhw
Copy link
Contributor Author

mchlrhw commented Apr 28, 2018

I think it's due in 1.27

@mchlrhw
Copy link
Contributor Author

mchlrhw commented Apr 28, 2018

Scratch that. I just looked on the stabilisation PR and it's slated for 1.26. Even better! 😁

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants