From f998727b4e47907c0c0f2744314d8c6d70ddc2c3 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Fri, 15 May 2020 23:05:38 +0800 Subject: [PATCH] Add oneshot::Sender::is_connected_to method --- futures-channel/src/oneshot.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/futures-channel/src/oneshot.rs b/futures-channel/src/oneshot.rs index 5f76cee4b9..8d160066fb 100644 --- a/futures-channel/src/oneshot.rs +++ b/futures-channel/src/oneshot.rs @@ -377,6 +377,12 @@ impl Sender { 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) -> bool { + Arc::ptr_eq(&self.inner, &receiver.inner) + } } impl Drop for Sender {