Skip to content
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

Add HashSet::get_or_insert_with_mut #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Commits on Feb 14, 2023

  1. Add HashSet::get_or_insert_with_mut

    This function avoids unnecessairy work when the value to be stored can
    take ownership of the lookup key, such as when interning.
    It makes a stronger guarantee than `HashSet::get_or_insert_with`, since
    the reference given to `f` is guaranteed to be unique, and thus safe to
    mutate.
    
    The functionality of this function can already be achieved by (ab)using
    `UnsafeCell`, but that relies on the implementation detail that the `&Q`
    given to `f` is unique.
    yyny committed Feb 14, 2023
    Configuration menu
    Copy the full SHA
    9340453 View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2023

  1. Document the expected invariants for get_or_insert_with and `get_or…

    …_insert_with_mut`
    yyny committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    739a8bd View commit details
    Browse the repository at this point in the history