-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
307 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters