From fd0b4d4cff21cb2ed2916cdfd991a6ecd112116e Mon Sep 17 00:00:00 2001 From: Shady Khalifa Date: Sun, 18 Aug 2019 09:50:34 +0200 Subject: [PATCH 1/2] missing .await (#69) * missing .await * Update tasks.md --- docs/src/concepts/tasks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/concepts/tasks.md b/docs/src/concepts/tasks.md index 881dadca..2208d301 100644 --- a/docs/src/concepts/tasks.md +++ b/docs/src/concepts/tasks.md @@ -17,7 +17,7 @@ async fn read_file(path: &str) -> Result { fn main() { let reader_task = task::spawn(async { - let result = read_file("data.csv"); + let result = read_file("data.csv").await; match result { Ok(s) => println!("{}", s), Err(e) => println!("Error reading file: {:?}", e) @@ -33,7 +33,7 @@ This asks the runtime baked into `async_std` to execute the code that reads a fi ```rust async { - let result = read_file("data.csv"); + let result = read_file("data.csv").await; match result { Ok(s) => println!("{}", s), Err(e) => println!("Error reading file: {:?}", e) From f57e3142a13bc927778d796601a36ab22d29bf97 Mon Sep 17 00:00:00 2001 From: Anthony Dodd Date: Sun, 18 Aug 2019 02:55:38 -0500 Subject: [PATCH 2/2] Small technical correction. (#64) Absolutely awesome work here! Just reading through the book absorbing all of the awesomeness and noticed this little bit. Let me know if you would like for me to update the corrections in any way. --- docs/src/concepts/futures.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/concepts/futures.md b/docs/src/concepts/futures.md index 31069ca8..32f6aa89 100644 --- a/docs/src/concepts/futures.md +++ b/docs/src/concepts/futures.md @@ -102,7 +102,7 @@ While the `Future` trait has existed in Rust for a while, it was inconvenient to Amazingly little difference, right? All we did is label the function `async` and insert 2 special commands: `.await`. -This function sets up a deferred computation. When this function is called, it will produce a `Future` instead of immediately returning a String. (Or, more precisely, generate a type for you that implements `Future`.) +This function sets up a deferred computation. When this function is called, it will produce a `Future>` instead of immediately returning the `Result`. (Or, more precisely, generate a type for you that implements `Future>`.) ## What does `.await` do?