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> {
2459
2459
}
2460
2460
2461
2461
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2462
- impl < R : Read > Iterator for Bytes < R > {
2462
+ impl < R : Read + SizeHint > Iterator for Bytes < R > {
2463
2463
type Item = Result < u8 > ;
2464
2464
2465
2465
fn next ( & mut self ) -> Option < Result < u8 > > {
@@ -2475,14 +2475,34 @@ impl<R: Read> Iterator for Bytes<R> {
2475
2475
}
2476
2476
2477
2477
default fn size_hint ( & self ) -> ( usize , Option < usize > ) {
2478
- ( 0 , None )
2478
+ self . inner . size_hint ( )
2479
2479
}
2480
2480
}
2481
2481
2482
2482
#[ 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
+
2484
2490
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 ( )
2486
2506
}
2487
2507
}
2488
2508
You can’t perform that action at this time.
0 commit comments