@@ -328,7 +328,7 @@ where
328
328
fn read_buf ( & mut self , mut cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
329
329
let prev_written = cursor. written ( ) ;
330
330
331
- Read :: read_buf ( & mut self . fill_buf ( ) ? , cursor. reborrow ( ) ) ?;
331
+ Read :: read_buf ( & mut self . remaining_slice ( ) , cursor. reborrow ( ) ) ?;
332
332
333
333
self . pos += ( cursor. written ( ) - prev_written) as u64 ;
334
334
@@ -352,17 +352,24 @@ where
352
352
}
353
353
354
354
fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < ( ) > {
355
- let n = buf. len ( ) ;
356
- Read :: read_exact ( & mut self . remaining_slice ( ) , buf) ?;
357
- self . pos += n as u64 ;
358
- Ok ( ( ) )
355
+ let result = Read :: read_exact ( & mut self . remaining_slice ( ) , buf) ;
356
+
357
+ match result {
358
+ Ok ( _) => self . pos += buf. len ( ) as u64 ,
359
+ // The only posible error condition is EOF
360
+ Err ( _) => self . pos = self . inner . as_ref ( ) . len ( ) as u64 ,
361
+ }
362
+
363
+ result
359
364
}
360
365
361
- fn read_buf_exact ( & mut self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
362
- let n = cursor. capacity ( ) ;
363
- Read :: read_buf_exact ( & mut self . remaining_slice ( ) , cursor) ?;
364
- self . pos += n as u64 ;
365
- Ok ( ( ) )
366
+ fn read_buf_exact ( & mut self , mut cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
367
+ let prev_written = cursor. written ( ) ;
368
+
369
+ let result = Read :: read_buf_exact ( & mut self . remaining_slice ( ) , cursor. reborrow ( ) ) ;
370
+ self . pos += ( cursor. written ( ) - prev_written) as u64 ;
371
+
372
+ result
366
373
}
367
374
368
375
fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
0 commit comments