-
Notifications
You must be signed in to change notification settings - Fork 322
Add hash_table::UnsafeIter, iter() method to various iterators
#667
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
3f35627 to
e2a7538
Compare
|
Rather than adding a whole new iterator kind, would it make more sense to direct users that need custom variance to the bucket iterator instead? |
|
That wouldn't really work because you would then need to mutably borrow the entire table inside the iterator, alongside the bucket iterator, to make it work, which would then give the same variance as Also because you might be confusing the raw bucket API with the one for |
|
I'm not super happy with this API, but I understand why it is necessary to implement |
|
I think giving it a longer, wordier name would probably be okay; part of my thought process was that it was better to offer a variant mut iterator over just offering an iterator without any lifetimes (i.e., over pointers), but in hindsight, I don't really know if that's worth it, since a correct use requires adding markers anyway. So, perhaps we could just convert this into an I've decided to adopt this new approach: it still has a lifetime, but only superficially. |
db9ea5d to
0b15891
Compare
hash_table::IterUnsafeMut, iter() method to various iteratorshash_table::UnsafeIter, iter() method to various iterators
0b15891 to
fc595f6
Compare
Head branch was pushed to by a user without write access
fc595f6 to
6b79f32
Compare
6b79f32 to
62c8c25
Compare
|
Everything should now properly compile. Got a bit lazy testing changes when dependencies were borked, but now they actually do work. |
Both of these would be useful for #666, and presumably other downstream hash table implementations.
First, the
iter()methods make it possible to implement downstreamDebugimplementations more easily, by letting iterators likeDrainbe paused and viewed immutably.Second, the new
unsafe_itermethod and correspondingUnsafeIterexists to make implementinghash_map::IterMuta bit more reasonable without being as unsafe. The struct docs should hopefully make its existence clear, but I would definitely love some extra scrutiny on that.