Skip to content

Commit

Permalink
Auto merge of #325 - Amanieu:fix_size_hint, r=Amanieu
Browse files Browse the repository at this point in the history
Fix underflow in RawIterRange::size_hint
  • Loading branch information
bors committed May 1, 2022
2 parents 21bfd9a + cf1602a commit a41bd76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,10 +1963,14 @@ impl<T> Iterator for RawIterRange<T> {
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
// We don't have an item count, so just guess based on the range size.
(
0,
Some(unsafe { offset_from(self.end, self.next_ctrl) + Group::WIDTH }),
)
let remaining_buckets = if self.end > self.next_ctrl {
unsafe { offset_from(self.end, self.next_ctrl) }
} else {
0
};

// Add a group width to include the group we are currently processing.
(0, Some(Group::WIDTH + remaining_buckets))
}
}

Expand Down

0 comments on commit a41bd76

Please sign in to comment.