File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -2459,7 +2459,7 @@ pub struct Bytes<R> {
24592459}
24602460
24612461#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2462- impl < R : Read > Iterator for Bytes < R > {
2462+ impl < R : Read + SizeHint > Iterator for Bytes < R > {
24632463 type Item = Result < u8 > ;
24642464
24652465 fn next ( & mut self ) -> Option < Result < u8 > > {
@@ -2475,14 +2475,34 @@ impl<R: Read> Iterator for Bytes<R> {
24752475 }
24762476
24772477 default fn size_hint ( & self ) -> ( usize , Option < usize > ) {
2478- ( 0 , None )
2478+ self . inner . size_hint ( )
24792479 }
24802480}
24812481
24822482#[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2483- impl < R : Read > Iterator for Bytes < BufReader < R > > {
2483+ trait SizeHint {
2484+ fn lower_bound ( & self ) -> usize ;
2485+
2486+ fn upper_bound ( & self ) -> Option < usize > {
2487+ None
2488+ }
2489+
24842490 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
2485- ( self . inner . buffer ( ) . len ( ) , None )
2491+ ( self . lower_bound ( ) , self . upper_bound ( ) )
2492+ }
2493+ }
2494+
2495+ #[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2496+ impl SizeHint for T {
2497+ fn lower_bound ( & self ) -> usize {
2498+ 0
2499+ }
2500+ }
2501+
2502+ #[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2503+ impl < T > SizeHint for BufReader < T > {
2504+ fn lower_bound ( & self ) -> usize {
2505+ self . buffer ( ) . len ( )
24862506 }
24872507}
24882508
You can’t perform that action at this time.
0 commit comments