Advance index when reading multiple bytes as well as one at a time
This commit is contained in:
parent
a00314d108
commit
4b957d8785
|
@ -122,7 +122,10 @@ impl<'a, 'b, R: Read, N: NestedValue> Decoder<'a, 'b, R, N> {
|
||||||
}
|
}
|
||||||
let mut bs = vec![0; n];
|
let mut bs = vec![0; n];
|
||||||
match self.read.read_exact(&mut bs) {
|
match self.read.read_exact(&mut bs) {
|
||||||
Ok(()) => Ok(bs),
|
Ok(()) => {
|
||||||
|
self.index += n;
|
||||||
|
Ok(bs)
|
||||||
|
}
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
if e.kind() == std::io::ErrorKind::UnexpectedEof {
|
if e.kind() == std::io::ErrorKind::UnexpectedEof {
|
||||||
Err(Error::Eof)
|
Err(Error::Eof)
|
||||||
|
|
Loading…
Reference in New Issue