-
Notifications
You must be signed in to change notification settings - Fork 316
Closed
Description
More context on urlo and my questionable code.
What operations are allowed on RawTable
while holding a RawIter
?
Per my reading, the implementation currently suggests:
- Required(?) for exposed behavior:
- non-mutating inspection of the
RawTable
erase
ing the most recently yieldedBucket
- non-mutating inspection of the
- Definitely not allowed (UB):
- anything that causes a reallocation
- erasing a bucket "ahead" of the iterator that has yet to be yielded
- Potentially allowed:
- erasing a bucket "behind" the iterator head that has previously been yielded but is not the most recently yielded bucket
I would benefit from the above "delayed erasing" being guaranteed sound (for the use case linked above).
Side note: it would be useful to make RawIter
's debug_assert
that it iterated all the expected items say what went wrong. Something simple like "exhausted iterator before expected; this likely indicates modification of a hash table while iterating it, which is UB" would definitely make hitting that assertion more obvious than the default message of "200 != 0" from inside of hashbrown's internals.
Metadata
Metadata
Assignees
Labels
No labels