forked from mirror/async-std
Fix some typos in tutorial (#98)
* fix typo in tutorial * add async_std::io::BufReader to tutorial code * writers in clean_shutdown.md return unit type
This commit is contained in:
parent
be616f35bf
commit
794c12fe7e
3 changed files with 3 additions and 2 deletions
|
@ -70,5 +70,5 @@ fn main() -> Result<()> {
|
|||
The crucial thing to realise that is in Rust, unlike other languages, calling an async function does **not** run any code.
|
||||
Async functions only construct futures, which are inert state machines.
|
||||
To start stepping through the future state-machine in an async function, you should use `.await`.
|
||||
In a non-async function, a way to execute a future is to handle it to the executor.
|
||||
In a non-async function, a way to execute a future is to hand it to the executor.
|
||||
In this case, we use `task::block_on` to execute a future on the current thread and block until it's done.
|
||||
|
|
|
@ -69,7 +69,7 @@ async fn broker(mut events: Receiver<Event>) -> Result<()> {
|
|||
}
|
||||
drop(peers); // 3
|
||||
for writer in writers { // 4
|
||||
writer.await?;
|
||||
writer.await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ We need to:
|
|||
```rust
|
||||
use async_std::io::BufReader;
|
||||
use async_std::net::TcpStream;
|
||||
use async_std::io::BufReader;
|
||||
|
||||
async fn server(addr: impl ToSocketAddrs) -> Result<()> {
|
||||
let listener = TcpListener::bind(addr).await?;
|
||||
|
|
Loading…
Reference in a new issue