Skip to content

channel: Fix misleading comment in Select::remove example#1291

Open
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:select-remove-example-comment
Open

channel: Fix misleading comment in Select::remove example#1291
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:select-remove-example-comment

Conversation

@teddytennant

Copy link
Copy Markdown
Contributor

What

Fixes a misleading comment in the Select::remove doc example. The example asserts oper.index() == oper2, but the comment above the select() call claimed "Both operations are initially ready, so a random one will be executed."

Why

Closes #721.

Only operation 2 is ready: r2 is disconnected, and a receive operation is considered ready even when it will simply return an error because the channel is disconnected. r1 is empty (nothing is sent on s1 until after the select), so receiving from it would block. That's why the assertions on oper2 always hold — the old comment contradicted them. The new wording matches the phrasing already used in the select() 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 remove in crossbeam-channel — passes

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
Copilot AI review requested due to automatic review settings July 11, 2026 17:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Confusing comment in crossbeam_channel::Select::remove example

2 participants