Skip to content

Commit ec7f9b9

Browse files
author
Federico Ponzi
committed
Deduplicates io::Write implementations
1 parent 28db521 commit ec7f9b9

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

library/std/src/io/stdio.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -584,26 +584,26 @@ impl fmt::Debug for Stdout {
584584
#[stable(feature = "rust1", since = "1.0.0")]
585585
impl Write for Stdout {
586586
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
587-
self.lock().write(buf)
587+
(&*self).write(buf)
588588
}
589589
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
590-
self.lock().write_vectored(bufs)
590+
(&*self).write_vectored(bufs)
591591
}
592592
#[inline]
593593
fn is_write_vectored(&self) -> bool {
594-
self.lock().is_write_vectored()
594+
io::Write::is_write_vectored(&&*self)
595595
}
596596
fn flush(&mut self) -> io::Result<()> {
597-
self.lock().flush()
597+
(&*self).flush()
598598
}
599599
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
600-
self.lock().write_all(buf)
600+
(&*self).write_all(buf)
601601
}
602602
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
603-
self.lock().write_all_vectored(bufs)
603+
(&*self).write_all_vectored(bufs)
604604
}
605605
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
606-
self.lock().write_fmt(args)
606+
(&*self).write_fmt(args)
607607
}
608608
}
609609

@@ -787,26 +787,26 @@ impl fmt::Debug for Stderr {
787787
#[stable(feature = "rust1", since = "1.0.0")]
788788
impl Write for Stderr {
789789
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
790-
self.lock().write(buf)
790+
(&*self).write(buf)
791791
}
792792
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
793-
self.lock().write_vectored(bufs)
793+
(&*self).write_vectored(bufs)
794794
}
795795
#[inline]
796796
fn is_write_vectored(&self) -> bool {
797-
self.lock().is_write_vectored()
797+
io::Write::is_write_vectored(&&*self)
798798
}
799799
fn flush(&mut self) -> io::Result<()> {
800-
self.lock().flush()
800+
(&*self).flush()
801801
}
802802
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
803-
self.lock().write_all(buf)
803+
(&*self).write_all(buf)
804804
}
805805
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
806-
self.lock().write_all_vectored(bufs)
806+
(&*self).write_all_vectored(bufs)
807807
}
808808
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
809-
self.lock().write_fmt(args)
809+
(&*self).write_fmt(args)
810810
}
811811
}
812812

library/std/src/process.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,19 @@ pub struct ChildStdin {
246246
#[stable(feature = "process", since = "1.0.0")]
247247
impl Write for ChildStdin {
248248
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
249-
self.inner.write(buf)
249+
(&*self).write(buf)
250250
}
251251

252252
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
253-
self.inner.write_vectored(bufs)
253+
(&*self).write_vectored(bufs)
254254
}
255255

256256
fn is_write_vectored(&self) -> bool {
257-
self.inner.is_write_vectored()
257+
io::Write::is_write_vectored(&&*self)
258258
}
259259

260260
fn flush(&mut self) -> io::Result<()> {
261-
Ok(())
261+
(&*self).flush()
262262
}
263263
}
264264

0 commit comments

Comments
 (0)