-
Notifications
You must be signed in to change notification settings - Fork 314
allow providing the key at insertion time for EntryRef #579
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
base: master
Are you sure you want to change the base?
Conversation
I expect we do want a full assert, just like we did in Line 957 in eea9804
|
i think i will drop the insert_clone as insert_kv already covers the usecase. should i make the full pr? |
I'll defer to @Amanieu to decide on the API design. |
f705fc8
to
afe3b0c
Compare
i disagree with clippy on this one. |
@Amanieu can i get some feedback on the api design here? i would like to start depending on the main hashbrown again. this saves clones when trying to insert in a loop. |
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.
Overall, I think the API additions make sense. I've added some comments on the specific.
And finally, the docs will need to be improved.
8bfe87c
to
760eb3e
Compare
EntryRef already has or_insert_with_key which is a bit of a name collision, so i am for now only adding the functionality to VacantEntryRef. |
@Amanieu i have integrated the suggestions. Unsure if the docs are enough, i mainly point to the regular insert docs instead of duplicating. This should be ready to merge now i think, i have rebased it on top of master. |
Either explicitly through insert_kv or implicitly through insert_clone.
I have added an assert in insert_kv just to be sure, but if it is only a logic error to insert a different key at an entry or is caught deeper in the stack it should be removed/changed to debug_assert.
If this is something the maintainers are interested in i can implement the EntryRef and OccupiedEntryRef variants and document them.