Skip to content

Commit

Permalink
Rollup merge of rust-lang#37527 - Mark-Simulacrum:mpsc-recvtimeouterr…
Browse files Browse the repository at this point in the history
…or-error-impl, r=alexcrichton

Add Error implementation for std::sync::mpsc::RecvTimeoutError.

Fixes rust-lang#37525.
  • Loading branch information
eddyb authored Nov 12, 2016
2 parents 16ae078 + 2af6111 commit 29195e2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29195e2

Please sign in to comment.