Add entry_ref API to HashMap by ajtribick · Pull Request #301 · rust-lang/hashbr...
source link: https://github.com/rust-lang/hashbrown/pull/301
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
An initial attempt at an entry_ref
API to do the simple case that raw_entry_mut
is used for. I basically attempted to mirror the existing entry
API, but allow passing a borrowed version of the key. I left off mirroring the Send
and Sync
traits as I'm not sure what these should be.
The relationships I use between the key K
and borrowed key Q
is K: Borrow<Q> + From<&Q>
. The reason for not using Q: ToOwned<K>
is to support key types like Rc<str>
(which is used in a couple of the doctests), which would not be possible with to_owned()
.
Hopefully this is somewhat useful.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK