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 @@ -2456,7 +2456,7 @@ pub struct Bytes<R> {
24562456}
24572457
24582458#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2459- impl < R : Read > Iterator for Bytes < R > {
2459+ impl < R : Read + SizeHint > Iterator for Bytes < R > {
24602460 type Item = Result < u8 > ;
24612461
24622462 fn next ( & mut self ) -> Option < Result < u8 > > {
@@ -2472,14 +2472,34 @@ impl<R: Read> Iterator for Bytes<R> {
24722472 }
24732473
24742474 default fn size_hint ( & self ) -> ( usize , Option < usize > ) {
2475- ( 0 , None )
2475+ self . inner . size_hint ( )
24762476 }
24772477}
24782478
24792479#[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2480- impl < R : Read > Iterator for Bytes < BufReader < R > > {
2480+ trait SizeHint {
2481+ fn lower_bound ( & self ) -> usize ;
2482+
2483+ fn upper_bound ( & self ) -> Option < usize > {
2484+ None
2485+ }
2486+
24812487 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
2482- ( self . inner . buffer ( ) . len ( ) , None )
2488+ ( self . lower_bound ( ) , self . upper_bound ( ) )
2489+ }
2490+ }
2491+
2492+ #[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2493+ impl SizeHint for T {
2494+ fn lower_bound ( & self ) -> usize {
2495+ 0
2496+ }
2497+ }
2498+
2499+ #[ stable( feature = "bufreader_size_hint" , since = "1.51.0" ) ]
2500+ impl < T > SizeHint for BufReader < T > {
2501+ fn lower_bound ( & self ) -> usize {
2502+ self . buffer ( ) . len ( )
24832503 }
24842504}
24852505
You can’t perform that action at this time.
0 commit comments