File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -598,6 +598,28 @@ fn extend_mut_from_bytes() {
598598 assert_eq ! ( * bytes, LONG [ ..] ) ;
599599}
600600
601+ #[ test]
602+ fn extend_past_lower_limit_of_size_hint ( ) {
603+ // See https://github.com/tokio-rs/bytes/pull/674#pullrequestreview-1913035700
604+ struct Iter < I > ( I ) ;
605+
606+ impl < I : Iterator < Item = u8 > > Iterator for Iter < I > {
607+ type Item = u8 ;
608+
609+ fn next ( & mut self ) -> Option < Self :: Item > {
610+ self . 0 . next ( )
611+ }
612+
613+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
614+ ( 5 , None )
615+ }
616+ }
617+
618+ let mut bytes = BytesMut :: with_capacity ( 5 ) ;
619+ bytes. extend ( Iter ( std:: iter:: repeat ( 0 ) . take ( 10 ) ) ) ;
620+ assert_eq ! ( bytes. len( ) , 10 ) ;
621+ }
622+
601623#[ test]
602624fn extend_mut_without_size_hint ( ) {
603625 let mut bytes = BytesMut :: with_capacity ( 0 ) ;
You can’t perform that action at this time.
0 commit comments