Skip to content

Commit ca024f9

Browse files
committed
primitives: fix min/max size hint in HrpFe32Iter
1 parent 5b862d4 commit ca024f9

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/primitives/checksum.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ impl Iterator for HrpFe32Iter<'_> {
502502
None => (0, Some(0)),
503503
};
504504

505-
let min = high.0 + 1 + low.0;
506-
let max = high.1.zip(low.1).map(|(high, low)| high + 1 + low);
505+
let min = high.0 + low.0;
506+
let max = high.1.zip(low.1).map(|(high, low)| high + low);
507507

508508
(min, max)
509509
}
@@ -599,6 +599,19 @@ mod tests {
599599
#[cfg(feature = "std")]
600600
println!("{}", _s);
601601
}
602+
603+
#[test]
604+
fn hrp_fe32_iter_size_hint_matches_remaining_length() {
605+
let hrp = Hrp::parse_unchecked("ab");
606+
let mut iter = HrpFe32Iter::new(&hrp);
607+
608+
for remaining in (0..=(2 * hrp.len() + 1)).rev() {
609+
assert_eq!(iter.size_hint(), (remaining, Some(remaining)));
610+
if remaining > 0 {
611+
iter.next().expect("iterator has more elements");
612+
}
613+
}
614+
}
602615
}
603616

604617
#[cfg(bench)]

0 commit comments

Comments
 (0)