Skip to content

Commit 4c55714

Browse files
authored
Merge pull request #184 from Amanieu/rawiter_rules
Document RawIter guarantees
2 parents 09e43a8 + 845b0f0 commit 4c55714

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/raw/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,17 @@ impl<T> Iterator for RawIterRange<T> {
14701470
impl<T> FusedIterator for RawIterRange<T> {}
14711471

14721472
/// Iterator which returns a raw pointer to every full bucket in the table.
1473+
///
1474+
/// For maximum flexibility this iterator is not bound by a lifetime, but you
1475+
/// must observe several rules when using it:
1476+
/// - You must not free the hash table while iterating (including via growing/shrinking).
1477+
/// - It is fine to erase a bucket that has been yielded by the iterator.
1478+
/// - Erasing a bucket that has not yet been yielded by the iterator may still
1479+
/// result in the iterator yielding that bucket (unless `reflect_remove` is called).
1480+
/// - It is unspecified whether an element inserted after the iterator was
1481+
/// created will be yielded by that iterator (unless `reflect_insert` is called).
1482+
/// - The order in which the iterator yields bucket is unspecified and may
1483+
/// change in the future.
14731484
pub struct RawIter<T> {
14741485
pub(crate) iter: RawIterRange<T>,
14751486
items: usize,

0 commit comments

Comments
 (0)