about summary refs log tree commit diff
path: root/src/libstd/io/impls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/io/impls.rs')
-rw-r--r--src/libstd/io/impls.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs
index bd3d0a41638..b286e4016da 100644
--- a/src/libstd/io/impls.rs
+++ b/src/libstd/io/impls.rs
@@ -165,6 +165,20 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
     }
 }
 
+// Used by panicking::default_hook
+#[cfg(test)]
+/// This impl is only used by printing logic, so any error returned is always
+/// of kind `Other`, and should be ignored.
+impl Write for Box<dyn (::realstd::io::Write) + Send> {
+    fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+        (**self).write(buf).map_err(|_| ErrorKind::Other.into())
+    }
+
+    fn flush(&mut self) -> io::Result<()> {
+        (**self).flush().map_err(|_| ErrorKind::Other.into())
+    }
+}
+
 // =============================================================================
 // In-memory buffer implementations