From 794c12fe7e9ba8c52ccc9f3e11206646b94cca07 Mon Sep 17 00:00:00 2001 From: Rui Loura Date: Fri, 23 Aug 2019 06:37:54 -0700 Subject: [PATCH] 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 --- docs/src/tutorial/accept_loop.md | 2 +- docs/src/tutorial/clean_shutdown.md | 2 +- docs/src/tutorial/receiving_messages.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/tutorial/accept_loop.md b/docs/src/tutorial/accept_loop.md index 8a91321..c46019d 100644 --- a/docs/src/tutorial/accept_loop.md +++ b/docs/src/tutorial/accept_loop.md @@ -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. diff --git a/docs/src/tutorial/clean_shutdown.md b/docs/src/tutorial/clean_shutdown.md index 714a926..0f54dac 100644 --- a/docs/src/tutorial/clean_shutdown.md +++ b/docs/src/tutorial/clean_shutdown.md @@ -69,7 +69,7 @@ async fn broker(mut events: Receiver) -> Result<()> { } drop(peers); // 3 for writer in writers { // 4 - writer.await?; + writer.await; } Ok(()) } diff --git a/docs/src/tutorial/receiving_messages.md b/docs/src/tutorial/receiving_messages.md index 286f091..3dc1903 100644 --- a/docs/src/tutorial/receiving_messages.md +++ b/docs/src/tutorial/receiving_messages.md @@ -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?;