From 00deeb35c8149508240549f5c9f3908a7ba9ee11 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Sun, 8 Nov 2020 01:46:05 +0200 Subject: [PATCH] Fix is_write_vectored in LineWriterShim Now that BufWriter always claims to support vectored writes, look through it at the wrapped writer to decide whether to use vectored writes for LineWriter. --- library/std/src/io/buffered/linewritershim.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/buffered/linewritershim.rs b/library/std/src/io/buffered/linewritershim.rs index a80d08db869..d0c859d2e0c 100644 --- a/library/std/src/io/buffered/linewritershim.rs +++ b/library/std/src/io/buffered/linewritershim.rs @@ -20,6 +20,12 @@ impl<'a, W: Write> LineWriterShim<'a, W> { Self { buffer } } + /// Get a reference to the inner writer (that is, the writer + /// wrapped by the BufWriter). + fn inner(&self) -> &W { + self.buffer.get_ref() + } + /// Get a mutable reference to the inner writer (that is, the writer /// wrapped by the BufWriter). Be careful with this writer, as writes to /// it will bypass the buffer. @@ -227,7 +233,7 @@ impl<'a, W: Write> Write for LineWriterShim<'a, W> { } fn is_write_vectored(&self) -> bool { - self.buffer.is_write_vectored() + self.inner().is_write_vectored() } /// Write some data into this BufReader with line buffering. This means