Skip to content

Import HashMap visibly in the tutorial #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/src/concepts/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, io::Error> {
let mut file = File::open(path).await?;
let mut contents = String::new();
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorial/all_together.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async fn client(mut broker: Sender<Event>, stream: TcpStream) -> Result<()> {
Some(idx) => (&line[..idx], line[idx + 1 ..].trim()),
};
let dest: Vec<String> = 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(),
Expand Down
7 changes: 3 additions & 4 deletions docs/src/tutorial/connecting_readers_and_writers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
# type Sender<T> = mpsc::UnboundedSender<T>;
Expand Down Expand Up @@ -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 {
Expand Down