Skip to content

Commit

Permalink
Merge pull request rust-lang#158 from stepancheg/send-error-debug
Browse files Browse the repository at this point in the history
impl Debug for SendError
  • Loading branch information
alexcrichton authored Sep 25, 2016
2 parents 0db9792 + 0cf2fdf commit 641cb10
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/stream/channel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::any::Any;
use std::error::Error;
use std::fmt;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};

Expand Down Expand Up @@ -71,6 +74,29 @@ enum Message<T> {

pub struct SendError<T, E>(Result<T, E>);

impl<T, E> fmt::Debug for SendError<T, E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_tuple("SendError")
.field(&"...")
.finish()
}
}

impl<T, E> fmt::Display for SendError<T, E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "send failed because receiver is gone")
}
}

impl<T, E> Error for SendError<T, E>
where T: Any, E: Any
{
fn description(&self) -> &str {
"send failed because receiver is gone"
}
}


impl<T, E> Stream for Receiver<T, E> {
type Item = T;
type Error = E;
Expand Down

0 comments on commit 641cb10

Please sign in to comment.