Skip to content

Commit

Permalink
Add oneshot::Sender::is_connected_to method (#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
canndrew committed Sep 5, 2020
1 parent 4d54611 commit cb696f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions futures-channel/src/oneshot.rs
Expand Up @@ -377,6 +377,12 @@ impl<T> Sender<T> {
pub fn is_canceled(&self) -> bool {
self.inner.is_canceled()
}

/// Tests to see whether this `Sender` is connected to the given `Receiver`. That is, whether
/// they were created by the same call to `channel`.
pub fn is_connected_to(&self, receiver: &Receiver<T>) -> bool {
Arc::ptr_eq(&self.inner, &receiver.inner)
}
}

impl<T> Drop for Sender<T> {
Expand Down

0 comments on commit cb696f9

Please sign in to comment.