Skip to content

Commit d501bf6

Browse files
authored
Merge pull request #112 from async-rs/fix-101
Import HashMap visibly in the tutorial
2 parents 5c17185 + 366546b commit d501bf6

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

docs/src/concepts/tasks.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ In `async-std`, the [`tasks`][tasks] module is responsible for this. The simples
66

77
```rust,edition2018
88
# extern crate async_std;
9-
# use async_std::{fs::File, io::Read, task};
10-
# use std::io;
11-
#
9+
use async_std::{io, task, fs::File, io::Read};
10+
1211
async fn read_file(path: &str) -> Result<String, io::Error> {
1312
let mut file = File::open(path).await?;
1413
let mut contents = String::new();

docs/src/tutorial/all_together.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async fn client(mut broker: Sender<Event>, stream: TcpStream) -> Result<()> {
7474
Some(idx) => (&line[..idx], line[idx + 1 ..].trim()),
7575
};
7676
let dest: Vec<String> = dest.split(',').map(|name| name.trim().to_string()).collect();
77-
let msg: String = msg.trim().to_string();
77+
let msg: String = msg.to_string();
7878
7979
broker.send(Event::Message { // 4
8080
from: name.clone(),

docs/src/tutorial/connecting_readers_and_writers.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined
2121
# };
2222
# use futures::channel::mpsc;
2323
# use futures::SinkExt;
24-
# use std::{
25-
# collections::hash_map::{Entry, HashMap},
26-
# sync::Arc,
27-
# };
24+
# use std::sync::Arc;
2825
#
2926
# type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
3027
# type Sender<T> = mpsc::UnboundedSender<T>;
@@ -52,6 +49,8 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined
5249
# })
5350
# }
5451
#
52+
use std::collections::hash_map::{Entry, HashMap};
53+
5554
#[derive(Debug)]
5655
enum Event { // 1
5756
NewPeer {

0 commit comments

Comments
 (0)