Skip to content

Commit

Permalink
Describe the select! arm behavior step-by-step (#1685)
Browse files Browse the repository at this point in the history
The original text describes several steps in one sentence. It's barely
decipherable. Use three sentences instead of one.
  • Loading branch information
proski authored Jan 12, 2024
1 parent dfa00b5 commit c662907
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/async/control-flow/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Python, it compares to
`asyncio.wait(task_set, return_when=asyncio.FIRST_COMPLETED)`.

Similar to a match statement, the body of `select!` has a number of arms, each
of the form `pattern = future => statement`. When the `future` is ready, the
`statement` is executed with the variables in `pattern` bound to the `future`'s
result.
of the form `pattern = future => statement`. When a `future` is ready, its
return value is destructured by the `pattern`. The `statement` is then run with
the resulting variables. The `statement` result becomes the result of the
`select!` macro.

```rust,editable,compile_fail
use tokio::sync::mpsc::{self, Receiver};
Expand Down

0 comments on commit c662907

Please sign in to comment.