From 9f5f5b7d7e766ce3e5ef5e10d850c30ea53e3f65 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 10 Oct 2017 11:52:35 -0400 Subject: [PATCH] Forward read_exact() as well as read(). 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 04f96391..87aa304d 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> {