diff --git a/src/lib.rs b/src/lib.rs index 245a216..0374376 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,6 +196,7 @@ pub struct Sender { } impl Sender { + /// Attempts to send a message into the channel. /// /// If the channel is full or closed, this method returns an error. @@ -493,6 +494,11 @@ impl Sender { channel: self.channel.clone(), } } + + /// Returns whether the senders belong to the same channel. + pub fn same_channel(&self, other: &Sender) -> bool { + Arc::ptr_eq(&self.channel, &other.channel) + } } impl Drop for Sender { @@ -820,6 +826,11 @@ impl Receiver { channel: self.channel.clone(), } } + + /// Returns whether the receivers belong to the same channel. + pub fn same_channel(&self, other: &Receiver) -> bool { + Arc::ptr_eq(&self.channel, &other.channel) + } } impl fmt::Debug for Receiver {