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

Create a version of get_or_insert that doesn't move the key #199

Merged
merged 1 commit into from
Jul 31, 2024

Commits on Jul 31, 2024

  1. Create versions of get_or_insert that don't move the key

    Four new methods are added:
    * get_or_insert_ref
    * try_get_or_insert_ref
    * get_or_insert_mut_ref
    * try_get_or_insert_mut_ref
    
    which are analog to their existing counterparts:
    * get_or_insert
    * try_get_or_insert
    * get_or_insert_mut
    * try_get_or_insert_mut
    
    with the difference of accepting a reference to the key instead of an owned object. If the key
    doesn't exist in the cache and needs to be moved, only then is it cloned using to_owned() so it can
    be owned by the cache. This is useful when cloning the key is expensive.
    lufte committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    9ff163d View commit details
    Browse the repository at this point in the history