File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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) ]
You can’t perform that action at this time.
0 commit comments