1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-15 14:27:50 +02:00

Describe the select! arm behavior step-by-step (#1685)

The original text describes several steps in one sentence. It's barely
decipherable. Use three sentences instead of one.
This commit is contained in:
Pavel Roskin 2024-01-12 06:47:13 -08:00 committed by GitHub
parent dfa00b5b09
commit c662907c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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};