Forward read_exact() as well as read(). (#207)

If we don't do this we end up using the generic read_exact method
which is not necessarily optimal. This is especially when
using a specialized Read implementation to go fast.
See https://github.com/TyOverby/bincode/issues/206
This commit is contained in:
Jeff Muizelaar 2017-10-10 13:20:34 -04:00 committed by Ty Overby
parent 78e40014f5
commit d033583700
1 changed files with 6 additions and 0 deletions

View File

@ -51,12 +51,18 @@ impl <'storage> io::Read for SliceReader<'storage> {
fn read(&mut self, out: & mut [u8]) -> io::Result<usize> {
(&mut self.slice).read(out)
}
fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> {
(&mut self.slice).read_exact(out)
}
}
impl <R: io::Read> io::Read for IoReader<R> {
fn read(&mut self, out: & mut [u8]) -> io::Result<usize> {
self.reader.read(out)
}
fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> {
self.reader.read_exact(out)
}
}
impl <'storage> SliceReader<'storage> {