channel: Fix misleading comment in Select::remove example#1291
Open
teddytennant wants to merge 1 commit into
Open
channel: Fix misleading comment in Select::remove example#1291teddytennant wants to merge 1 commit into
teddytennant wants to merge 1 commit into
Conversation
The example asserts that operation 2 is always selected, but the comment claimed both operations are ready and a random one is executed. Only r2 is ready, because it is disconnected; r1 is empty, so receiving from it would block. Update the comment to match the asserted behavior, using the same wording as the select() docs. Closes crossbeam-rs#721
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes a misleading comment in the
Select::removedoc example. The example assertsoper.index() == oper2, but the comment above theselect()call claimed "Both operations are initially ready, so a random one will be executed."Why
Closes #721.
Only operation 2 is ready:
r2is disconnected, and a receive operation is considered ready even when it will simply return an error because the channel is disconnected.r1is empty (nothing is sent ons1until after the select), so receiving from it would block. That's why the assertions onoper2always hold — the old comment contradicted them. The new wording matches the phrasing already used in theselect()docs for the same situation.Testing
Comment-only change inside a doc example; the example's assertions already pin the behavior the comment now describes.
cargo test --doc removeincrossbeam-channel— passes