Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add oneshot::Sender::is_connected_to method #2158

Merged
merged 2 commits into from Sep 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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