@@ -328,7 +328,7 @@ where
328328 fn read_buf ( & mut self , mut cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
329329 let prev_written = cursor. written ( ) ;
330330
331- Read :: read_buf ( & mut self . fill_buf ( ) ? , cursor. reborrow ( ) ) ?;
331+ Read :: read_buf ( & mut self . remaining_slice ( ) , cursor. reborrow ( ) ) ?;
332332
333333 self . pos += ( cursor. written ( ) - prev_written) as u64 ;
334334
@@ -352,17 +352,24 @@ where
352352 }
353353
354354 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
359364 }
360365
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
366373 }
367374
368375 fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
0 commit comments