From bfaa9c510cfb18df3c6010c42d30d7ec4f7abcd0 Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Mon, 26 Aug 2019 14:33:11 -0700 Subject: [PATCH 1/3] Import HashMap visibly in the tutorial Fixes #101 --- docs/src/tutorial/connecting_readers_and_writers.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/tutorial/connecting_readers_and_writers.md b/docs/src/tutorial/connecting_readers_and_writers.md index 7aba3a13..31631f88 100644 --- a/docs/src/tutorial/connecting_readers_and_writers.md +++ b/docs/src/tutorial/connecting_readers_and_writers.md @@ -21,10 +21,7 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined # }; # use futures::channel::mpsc; # use futures::SinkExt; -# use std::{ -# collections::hash_map::{Entry, HashMap}, -# sync::Arc, -# }; +# use std::sync::Arc; # # type Result = std::result::Result>; # type Sender = mpsc::UnboundedSender; @@ -52,6 +49,8 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined # }) # } # +use std::collections::hash_map::{Entry, HashMap}; + #[derive(Debug)] enum Event { // 1 NewPeer { From b768a7bab7688a0aa605ddb295fe61b42a16914f Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Mon, 26 Aug 2019 14:35:57 -0700 Subject: [PATCH 2/3] Don't trim msg twice Fixes #102 --- docs/src/tutorial/all_together.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/tutorial/all_together.md b/docs/src/tutorial/all_together.md index 4e81cb20..352d6925 100644 --- a/docs/src/tutorial/all_together.md +++ b/docs/src/tutorial/all_together.md @@ -74,7 +74,7 @@ async fn client(mut broker: Sender, stream: TcpStream) -> Result<()> { Some(idx) => (&line[..idx], line[idx + 1 ..].trim()), }; let dest: Vec = dest.split(',').map(|name| name.trim().to_string()).collect(); - let msg: String = msg.trim().to_string(); + let msg: String = msg.to_string(); broker.send(Event::Message { // 4 from: name.clone(), From 366546b9cec777f4dc9e52659b3f7c81d55de192 Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Mon, 26 Aug 2019 14:39:25 -0700 Subject: [PATCH 3/3] Visibly import in tasks example Fixes #97 --- docs/src/concepts/tasks.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/src/concepts/tasks.md b/docs/src/concepts/tasks.md index 5c62811a..0711c126 100644 --- a/docs/src/concepts/tasks.md +++ b/docs/src/concepts/tasks.md @@ -6,9 +6,8 @@ In `async-std`, the [`tasks`][tasks] module is responsible for this. The simples ```rust,edition2018 # extern crate async_std; -# use async_std::{fs::File, io::Read, task}; -# use std::io; -# +use async_std::{io, task, fs::File, io::Read}; + async fn read_file(path: &str) -> Result { let mut file = File::open(path).await?; let mut contents = String::new();