From cb696f90b287bffa754bad6dd4733017adcdaa92 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Sat, 5 Sep 2020 09:49:40 +0800 Subject: [PATCH] Add oneshot::Sender::is_connected_to method (#2158) --- 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 {