about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorMark-Simulacrum <mark.simulacrum@gmail.com>2016-11-01 19:06:51 -0600
committerMark-Simulacrum <mark.simulacrum@gmail.com>2016-11-02 08:59:55 -0600
commit2af61112d4cbe1b0a7ae4afd99ef387002b7a7de (patch)
treed24d3f2e5ff74da462f6cdfe4f4b40458a68ea95 /src/libstd/sync
parentea4b94dab0d526135dd658d3a314cc5462d439b0 (diff)
downloadrust-2af61112d4cbe1b0a7ae4afd99ef387002b7a7de.tar.gz
rust-2af61112d4cbe1b0a7ae4afd99ef387002b7a7de.zip
Add Error implementation for std::sync::mpsc::RecvTimeoutError.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/mpsc/mod.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs
index fce640e7c7a..2773629c7d7 100644
--- a/src/libstd/sync/mpsc/mod.rs
+++ b/src/libstd/sync/mpsc/mod.rs
@@ -1267,6 +1267,38 @@ impl error::Error for TryRecvError {
     }
 }
 
+#[stable(feature = "mpsc_recv_timeout_error", since = "1.14.0")]
+impl fmt::Display for RecvTimeoutError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match *self {
+            RecvTimeoutError::Timeout => {
+                "timed out waiting on channel".fmt(f)
+            }
+            RecvTimeoutError::Disconnected => {
+                "channel is empty and sending half is closed".fmt(f)
+            }
+        }
+    }
+}
+
+#[stable(feature = "mpsc_recv_timeout_error", since = "1.14.0")]
+impl error::Error for RecvTimeoutError {
+    fn description(&self) -> &str {
+        match *self {
+            RecvTimeoutError::Timeout => {
+                "timed out waiting on channel"
+            }
+            RecvTimeoutError::Disconnected => {
+                "channel is empty and sending half is closed"
+            }
+        }
+    }
+
+    fn cause(&self) -> Option<&error::Error> {
+        None
+    }
+}
+
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
     use env;