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

Conversation

canndrew
Copy link
Contributor

I was gonna open an issue asking for this, but it was trivial to implement so I figured I'd just go straight to a PR.

This adds a method to oneshot::Sender to check whether it's connected to a given Receiver:

/// 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)
}

Does this seem like a good idea? It would be useful for me.

@taiki-e taiki-e merged commit cb696f9 into rust-lang:master Sep 5, 2020
@taiki-e
Copy link
Member

taiki-e commented Sep 5, 2020

Thanks!

@taiki-e taiki-e mentioned this pull request Oct 5, 2020
@taiki-e taiki-e added the A-channel Area: futures::channel label Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-channel Area: futures::channel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants