Skip to content

Commit a41bd76

Browse files
committed
Auto merge of #325 - Amanieu:fix_size_hint, r=Amanieu
Fix underflow in RawIterRange::size_hint
2 parents 21bfd9a + cf1602a commit a41bd76

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/raw/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,10 +1963,14 @@ impl<T> Iterator for RawIterRange<T> {
19631963
#[inline]
19641964
fn size_hint(&self) -> (usize, Option<usize>) {
19651965
// We don't have an item count, so just guess based on the range size.
1966-
(
1967-
0,
1968-
Some(unsafe { offset_from(self.end, self.next_ctrl) + Group::WIDTH }),
1969-
)
1966+
let remaining_buckets = if self.end > self.next_ctrl {
1967+
unsafe { offset_from(self.end, self.next_ctrl) }
1968+
} else {
1969+
0
1970+
};
1971+
1972+
// Add a group width to include the group we are currently processing.
1973+
(0, Some(Group::WIDTH + remaining_buckets))
19701974
}
19711975
}
19721976

0 commit comments

Comments
 (0)