Skip to content

Commit f2ca3f3

Browse files
author
Stjepan Glavina
committed
Fix build errors in docs
1 parent a97d26c commit f2ca3f3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

docs/src/concepts/futures.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Remember the talk about "deferred computation" in the intro? That's all it is. I
5151
Let's have a look at a simple function, specifically the return value:
5252

5353
```rust,edition2018
54-
# use std::{fs::File, io::{self, Read}};
54+
# use std::{fs::File, io, io::prelude::*};
5555
#
56-
fn read_file(path: &str) -> Result<String, io::Error> {
56+
fn read_file(path: &str) -> io::Result<String> {
5757
let mut file = File::open(path)?;
5858
let mut contents = String::new();
5959
file.read_to_string(&mut contents)?;
@@ -69,7 +69,7 @@ But we wanted to abstract over *computation* and let someone else choose how to
6969
```rust,edition2018
7070
# use std::{fs::File, io::{self, Read}};
7171
#
72-
fn read_file(path: &str) -> Result<String, io::Error> {
72+
fn read_file(path: &str) -> io::Result<String> {
7373
let mut file = File::open(path)?;
7474
let mut contents = String::new();
7575
file.read_to_string(&mut contents)?;
@@ -112,9 +112,9 @@ While the `Future` trait has existed in Rust for a while, it was inconvenient to
112112

113113
```rust,edition2018
114114
# extern crate async_std;
115-
# use async_std::{fs::File, io, prelude::*};
115+
# use async_std::{fs::File, io, io::prelude::*};
116116
#
117-
async fn read_file(path: &str) -> Result<String, io::Error> {
117+
async fn read_file(path: &str) -> io::Result<String> {
118118
let mut file = File::open(path).await?;
119119
let mut contents = String::new();
120120
file.read_to_string(&mut contents).await?;
@@ -124,7 +124,7 @@ async fn read_file(path: &str) -> Result<String, io::Error> {
124124

125125
Amazingly little difference, right? All we did is label the function `async` and insert 2 special commands: `.await`.
126126

127-
This `async` function sets up a deferred computation. When this function is called, it will produce a `Future<Output=Result<String, io::Error>>` instead of immediately returning a `Result<String, io::Error>`. (Or, more precisely, generate a type for you that implements `Future<Output=Result<String, io::Error>>`.)
127+
This `async` function sets up a deferred computation. When this function is called, it will produce a `Future<Output = io::Result<String>>` instead of immediately returning a `io::Result<String>`. (Or, more precisely, generate a type for you that implements `Future<Output = io::Result<String>>`.)
128128

129129
## What does `.await` do?
130130

docs/src/concepts/tasks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In `async-std`, the [`tasks`][tasks] module is responsible for this. The simples
88
# extern crate async_std;
99
use async_std::{fs::File, io, prelude::*, task};
1010
11-
async fn read_file(path: &str) -> Result<String, io::Error> {
11+
async fn read_file(path: &str) -> io::Result<String> {
1212
let mut file = File::open(path).await?;
1313
let mut contents = String::new();
1414
file.read_to_string(&mut contents).await?;
@@ -33,9 +33,9 @@ This asks the runtime baked into `async_std` to execute the code that reads a fi
3333

3434
```rust,edition2018
3535
# extern crate async_std;
36-
# use async_std::{fs::File, prelude::*, task};
36+
# use async_std::{fs::File, io, prelude::*, task};
3737
#
38-
# async fn read_file(path: &str) -> Result<String, io::Error> {
38+
# async fn read_file(path: &str) -> io::Result<String> {
3939
# let mut file = File::open(path).await?;
4040
# let mut contents = String::new();
4141
# file.read_to_string(&mut contents).await?;

0 commit comments

Comments
 (0)