Fix KeySetIter panic when only leading bit is set
This commit is contained in:
parent
95d5a18e99
commit
fcd4fbadbc
1 changed files with 3 additions and 2 deletions
|
|
@ -108,13 +108,14 @@ impl core::iter::Iterator for KeySetIter {
|
||||||
type Item = u8;
|
type Item = u8;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let next_shift = self.key_set.0.trailing_zeros() as u8 + 1;
|
let next_shift = self.key_set.0.trailing_zeros() as u8;
|
||||||
if next_shift >= 128 {
|
if next_shift >= 128 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.key_set.0 >>= next_shift;
|
self.key_set.0 >>= next_shift;
|
||||||
self.shift += next_shift;
|
self.key_set.0 >>= 1;
|
||||||
|
self.shift += next_shift + 1;
|
||||||
|
|
||||||
Some(self.shift - 1)
|
Some(self.shift - 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue