From ec7f9b927f1896c7f29c602d6b0f961c891d0941 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Fri, 11 Sep 2020 11:11:34 +0200 Subject: [PATCH] Deduplicates io::Write implementations --- library/std/src/io/stdio.rs | 28 ++++++++++++++-------------- library/std/src/process.rs | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index f320cf907c3..cccc0aadf99 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -584,26 +584,26 @@ impl fmt::Debug for Stdout { #[stable(feature = "rust1", since = "1.0.0")] impl Write for Stdout { fn write(&mut self, buf: &[u8]) -> io::Result { - self.lock().write(buf) + (&*self).write(buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - self.lock().write_vectored(bufs) + (&*self).write_vectored(bufs) } #[inline] fn is_write_vectored(&self) -> bool { - self.lock().is_write_vectored() + io::Write::is_write_vectored(&&*self) } fn flush(&mut self) -> io::Result<()> { - self.lock().flush() + (&*self).flush() } fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.lock().write_all(buf) + (&*self).write_all(buf) } fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { - self.lock().write_all_vectored(bufs) + (&*self).write_all_vectored(bufs) } fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> { - self.lock().write_fmt(args) + (&*self).write_fmt(args) } } @@ -787,26 +787,26 @@ impl fmt::Debug for Stderr { #[stable(feature = "rust1", since = "1.0.0")] impl Write for Stderr { fn write(&mut self, buf: &[u8]) -> io::Result { - self.lock().write(buf) + (&*self).write(buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - self.lock().write_vectored(bufs) + (&*self).write_vectored(bufs) } #[inline] fn is_write_vectored(&self) -> bool { - self.lock().is_write_vectored() + io::Write::is_write_vectored(&&*self) } fn flush(&mut self) -> io::Result<()> { - self.lock().flush() + (&*self).flush() } fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.lock().write_all(buf) + (&*self).write_all(buf) } fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { - self.lock().write_all_vectored(bufs) + (&*self).write_all_vectored(bufs) } fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> { - self.lock().write_fmt(args) + (&*self).write_fmt(args) } } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 36521fdaec0..d620a720be3 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -246,19 +246,19 @@ pub struct ChildStdin { #[stable(feature = "process", since = "1.0.0")] impl Write for ChildStdin { fn write(&mut self, buf: &[u8]) -> io::Result { - self.inner.write(buf) + (&*self).write(buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - self.inner.write_vectored(bufs) + (&*self).write_vectored(bufs) } fn is_write_vectored(&self) -> bool { - self.inner.is_write_vectored() + io::Write::is_write_vectored(&&*self) } fn flush(&mut self) -> io::Result<()> { - Ok(()) + (&*self).flush() } }