diff options
Diffstat (limited to 'src/blocking/reader.rs')
-rw-r--r-- | src/blocking/reader.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/blocking/reader.rs b/src/blocking/reader.rs index 609c393..f4a51a8 100644 --- a/src/blocking/reader.rs +++ b/src/blocking/reader.rs @@ -33,7 +33,11 @@ impl<T: std::io::Read> Reader<T> { if bytes == 0 { return Err(crate::Error::EOF); } - self.parser.add_bytes(&self.buf[..bytes]); + self.parser.add_bytes( + // read() returning a value means that that many bytes are + // guaranteed to be available + self.buf.get(..bytes).unwrap_or_else(|| unreachable!()), + ); } } |