From d033583700ad6daa0c665d05053f3ae1797cb3e7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 10 Oct 2017 13:20:34 -0400 Subject: [PATCH] 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 --- src/de/read.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/de/read.rs b/src/de/read.rs index 04f9639..87aa304 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -51,12 +51,18 @@ impl <'storage> io::Read for SliceReader<'storage> { fn read(&mut self, out: & mut [u8]) -> io::Result { (&mut self.slice).read(out) } + fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> { + (&mut self.slice).read_exact(out) + } } impl io::Read for IoReader { fn read(&mut self, out: & mut [u8]) -> io::Result { self.reader.read(out) } + fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> { + self.reader.read_exact(out) + } } impl <'storage> SliceReader<'storage> {