Update the book tutorial to use async_std channels
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
With #380 landed, we should update the tutorial to use them. This would remove the final dependency on `futures-rs` (and importantly: `Sink`) which should be a big step up in terms of usability.
Also we should consider moving from `select! {}` to `Stream::merge`. From chat with @skade we've figured out how to "send a `close` message after a stream has been exhausted":
```rust
enum EventKind {
Event(/* event_type */),
Shutdown,
}
let events = events.map(|ev| EventKind::Event(ev)).join(stream::once(EventKind::Shutdown));
let shutdown = shutdown.map(|e| EventKind::Event(e));
let s = events.merge(shutdown);
while let Some(event) = s.next().await {
match event {
EventKind::Event(ev) => /* handle event */,
EventKind::Shutdown => /* handle shutdown */,
}
}
```
@skade I'm assigning this to you as you've been working on updating this recently. Feel free to unassign yourself if you don't think you'll have bandwidth. Thanks!
__edit:__ this would resolve https://github.com/async-rs/async-std/pull/105 and #13
Contributor guide
Assessment
This issue has not been assessed yet.