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 sync::watch::Sender::borrow method #3269

Merged
merged 2 commits into from Dec 14, 2020

Conversation

JOT85
Copy link
Contributor

@JOT85 JOT85 commented Dec 13, 2020

Motivation

The watch::Receiver type has the borrow method, to borrow the value last sent.

The watch::Sender also has access to this, but it isn't exposed. It would be nice to have this when passing around a Sender since it enables someone to check what has last been sent.

Solution

I've added an identical borrow method to sync::watch::Sender, along with some tests for the borrow method in general.

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync labels Dec 13, 2020
@Darksonn
Copy link
Contributor

Hm, interesting. In any case, this isn't the most important method (that is send), so this shouldn't be at the top of the documentation.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@carllerche
Copy link
Member

@Darksonn good call. I will hold off merging

@JOT85
Copy link
Contributor Author

JOT85 commented Dec 13, 2020

Hm, interesting. In any case, this isn't the most important method (that is send), so this shouldn't be at the top of the documentation.

Thanks! Updated in b364216. I've placed it after send and before is_closed, I think that's a sensible place?

@Darksonn
Copy link
Contributor

That is fine with me.

@carllerche carllerche merged commit 1f862d2 into tokio-rs:master Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants