-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
sync: add more oneshot examples #4153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not a real reviewer here, but I try to pay it back a bit)
This looks sane to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me!
/// ``` | ||
/// | ||
/// To use a `Sender` from a destructor, put it in an [`Option`] and call | ||
/// [`Option::take`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I ask why it's recommended to wrap Sender
in an Option
here? I can't seem to find a rationale!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you try removing the option, it should quickly become clear: it wont compile without it. Calling send
on an oneshot channel destroys the sender.
Some examples are duplicated both on the module and
Sender
orReceiver
structs to make them more easily discoverable.