diff options
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/mod.rs | 15 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 42 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 22 |
3 files changed, 79 insertions, 0 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index b07da0dc268..143a85ae321 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1444,6 +1444,16 @@ pub struct Chain<T, U> { done_first: bool, } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") + .field("t", &self.first) + .field("u", &self.second) + .finish() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<T: Read, U: Read> Read for Chain<T, U> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { @@ -1485,6 +1495,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> { /// /// [`take()`]: trait.Read.html#method.take #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Take<T> { inner: T, limit: u64, @@ -1602,6 +1613,7 @@ fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> { /// /// [`bytes()`]: trait.Read.html#method.bytes #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Bytes<R> { inner: R, } @@ -1623,6 +1635,7 @@ impl<R: Read> Iterator for Bytes<R> { /// [chars]: trait.Read.html#method.chars #[unstable(feature = "io", reason = "awaiting stability of Read::chars", issue = "27802")] +#[derive(Debug)] pub struct Chars<R> { inner: R, } @@ -1712,6 +1725,7 @@ impl fmt::Display for CharsError { /// /// [split]: trait.BufRead.html#method.split #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Split<B> { buf: B, delim: u8, @@ -1743,6 +1757,7 @@ impl<B: BufRead> Iterator for Split<B> { /// /// [lines]: trait.BufRead.html#method.lines #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Lines<B> { buf: B, } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 1a65bee13b8..9d1c8942f8c 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -282,6 +282,13 @@ impl Stdin { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Stdin { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Stdin { .. }") + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { @@ -314,6 +321,13 @@ impl<'a> BufRead for StdinLock<'a> { fn consume(&mut self, n: usize) { self.inner.consume(n) } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<'a> fmt::Debug for StdinLock<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("StdinLock { .. }") + } +} + /// A handle to the global standard output stream of the current process. /// /// Each handle shares a global buffer of data to be written to the standard @@ -424,6 +438,13 @@ impl Stdout { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Stdout { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Stdout { .. }") + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Write for Stdout { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { @@ -449,6 +470,13 @@ impl<'a> Write for StdoutLock<'a> { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<'a> fmt::Debug for StdoutLock<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("StdoutLock { .. }") + } +} + /// A handle to the standard error stream of a process. /// /// For more information, see the [`io::stderr`] method. @@ -545,6 +573,13 @@ impl Stderr { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Stderr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Stderr { .. }") + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Write for Stderr { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { @@ -570,6 +605,13 @@ impl<'a> Write for StderrLock<'a> { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<'a> fmt::Debug for StderrLock<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("StderrLock { .. }") + } +} + /// Resets the thread-local stderr handle to the specified writer /// /// This will replace the current thread's stderr handle, returning the old diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2c6880281b5..436511031ef 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -10,6 +10,7 @@ #![allow(missing_copy_implementations)] +use fmt; use io::{self, Read, Write, ErrorKind, BufRead}; /// Copies the entire contents of a reader into a writer. @@ -97,6 +98,13 @@ impl BufRead for Empty { fn consume(&mut self, _n: usize) {} } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") + } +} + /// A reader which yields one byte over and over and over and over and over and... /// /// This struct is generally created by calling [`repeat()`][repeat]. Please @@ -133,6 +141,13 @@ impl Read for Repeat { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") + } +} + /// A writer which will move data into the void. /// /// This struct is generally created by calling [`sink()`][sink]. Please @@ -165,6 +180,13 @@ impl Write for Sink { fn flush(&mut self) -> io::Result<()> { Ok(()) } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") + } +} + #[cfg(test)] mod tests { use io::prelude::*; |
