Advance index when reading multiple bytes as well as one at a time

This commit is contained in:
Tony Garnock-Jones 2019-10-19 23:26:44 +01:00
parent a00314d108
commit 4b957d8785
1 changed files with 4 additions and 1 deletions

View File

@ -122,7 +122,10 @@ impl<'a, 'b, R: Read, N: NestedValue> Decoder<'a, 'b, R, N> {
}
let mut bs = vec![0; n];
match self.read.read_exact(&mut bs) {
Ok(()) => Ok(bs),
Ok(()) => {
self.index += n;
Ok(bs)
}
Err(e) =>
if e.kind() == std::io::ErrorKind::UnexpectedEof {
Err(Error::Eof)