Skip to content

Commit 5dbcc98

Browse files
committed
Override read_exact and write_all
Some types override these methods to provide optimizations. Using default implementations would bypass those overrides and lead to worse performance. Overriding the methods to delegate implementations directly solves the problem.
1 parent 39cec17 commit 5dbcc98

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,10 @@ where
10511051
for_both!(*self, ref mut inner => inner.read(buf))
10521052
}
10531053

1054+
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
1055+
for_both!(*self, ref mut inner => inner.read_exact(buf))
1056+
}
1057+
10541058
fn read_to_end(&mut self, buf: &mut std::vec::Vec<u8>) -> io::Result<usize> {
10551059
for_both!(*self, ref mut inner => inner.read_to_end(buf))
10561060
}
@@ -1099,6 +1103,10 @@ where
10991103
for_both!(*self, ref mut inner => inner.write(buf))
11001104
}
11011105

1106+
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
1107+
for_both!(*self, ref mut inner => inner.write_all(buf))
1108+
}
1109+
11021110
fn flush(&mut self) -> io::Result<()> {
11031111
for_both!(*self, ref mut inner => inner.flush())
11041112
}

0 commit comments

Comments
 (0)