diff options
| author | bors <bors@rust-lang.org> | 2015-03-10 11:53:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-10 11:53:54 +0000 |
| commit | 5f47c0613ed4eb46fca3633c1297364c09e5e451 (patch) | |
| tree | 3463ff4b45d857c056bb02a820dd2b7f841c5e7b /src/libstd | |
| parent | d3c49d2140fc65e8bb7d7cf25bfe74dda6ce5ecf (diff) | |
| parent | b0357ac2c2c25404c9e91abebc2510fdac022665 (diff) | |
| download | rust-5f47c0613ed4eb46fca3633c1297364c09e5e451.tar.gz rust-5f47c0613ed4eb46fca3633c1297364c09e5e451.zip | |
Auto merge of #23248 - Manishearth:rollup, r=Manishearth
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 1a1e9e69e71..2ae1d4a9d50 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -318,6 +318,7 @@ use prelude::v1::*; use sync::Arc; +use error; use fmt; use mem; use cell::UnsafeCell; @@ -976,6 +977,18 @@ impl<T> fmt::Display for SendError<T> { } #[stable(feature = "rust1", since = "1.0.0")] +impl<T> error::Error for SendError<T> { + + fn description(&self) -> &str { + "sending on a closed channel" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl<T> fmt::Debug for TrySendError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -1000,6 +1013,25 @@ impl<T> fmt::Display for TrySendError<T> { } #[stable(feature = "rust1", since = "1.0.0")] +impl<T> error::Error for TrySendError<T> { + + fn description(&self) -> &str { + match *self { + TrySendError::Full(..) => { + "sending on a full channel" + } + TrySendError::Disconnected(..) => { + "sending on a closed channel" + } + } + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for RecvError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { "receiving on a closed channel".fmt(f) @@ -1007,6 +1039,18 @@ impl fmt::Display for RecvError { } #[stable(feature = "rust1", since = "1.0.0")] +impl error::Error for RecvError { + + fn description(&self) -> &str { + "receiving on a closed channel" + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for TryRecvError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -1020,6 +1064,25 @@ impl fmt::Display for TryRecvError { } } +#[stable(feature = "rust1", since = "1.0.0")] +impl error::Error for TryRecvError { + + fn description(&self) -> &str { + match *self { + TryRecvError::Empty => { + "receiving on an empty channel" + } + TryRecvError::Disconnected => { + "receiving on a closed channel" + } + } + } + + fn cause(&self) -> Option<&error::Error> { + None + } +} + #[cfg(test)] mod test { use prelude::v1::*; |
