-
Notifications
You must be signed in to change notification settings - Fork 292
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 entry_ref API to HashMap #301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I'm really glad to see this feature, it was much needed!
cc @rust-lang/libs-api since this API is likely to come to the standard library HashMap
soon and I would like to iterate on the API within the hashbrown
repo first.
src/map.rs
Outdated
} | ||
|
||
impl<'a, K, Q: ?Sized> KeyOrRef<'a, K, Q> { | ||
pub fn into_owned(self) -> K |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeyOrRef
is a private type, so this method doesn't need to be pub
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated.
I'm not sure why the update triggered the clippy warning for missing safety docs on the |
It's most likely because CI always uses the latest rust nightly and this lint was recently added to clippy. I think you can safely just disable this lint. This |
Ok, lint is disabled. Regarding the |
For |
Thanks! Added the impls. |
@bors r+ |
📌 Commit 7c545e1 has been approved by |
☀️ Test successful - checks-actions |
An initial attempt at an
entry_ref
API to do the simple case thatraw_entry_mut
is used for. I basically attempted to mirror the existingentry
API, but allow passing a borrowed version of the key. I left off mirroring theSend
andSync
traits as I'm not sure what these should be.The relationships I use between the key
K
and borrowed keyQ
isK: Borrow<Q> + From<&Q>
. The reason for not usingQ: ToOwned<K>
is to support key types likeRc<str>
(which is used in a couple of the doctests), which would not be possible withto_owned()
.Hopefully this is somewhat useful.