Skip to content

Commit d7651bb

Browse files
funkillcramertj
authored andcommitted
fixed editions and ignoring
1 parent 658ce12 commit d7651bb

File tree

14 files changed

+79
-59
lines changed

14 files changed

+79
-59
lines changed

src/02_execution/02_future.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ must register `wake` to be called when data becomes ready on the socket,
3030
which will tell the executor that our future is ready to make progress.
3131
A simple `SocketRead` future might look something like this:
3232

33-
```rust
33+
```rust,ignore
3434
{{#include ../../examples/02_02_future_trait/src/lib.rs:socket_read}}
3535
```
3636

@@ -39,15 +39,15 @@ operations without needing intermediate allocations. Running multiple futures
3939
at once or chaining futures together can be implemented via allocation-free
4040
state machines, like this:
4141

42-
```rust
42+
```rust,ignore
4343
{{#include ../../examples/02_02_future_trait/src/lib.rs:join}}
4444
```
4545

4646
This shows how multiple futures can be run simultaneously without needing
4747
separate allocations, allowing for more efficient asynchronous programs.
4848
Similarly, multiple sequential futures can be run one after another, like this:
4949

50-
```rust
50+
```rust,ignore
5151
{{#include ../../examples/02_02_future_trait/src/lib.rs:and_then}}
5252
```
5353

@@ -56,12 +56,12 @@ control flow without requiring multiple allocated objects and deeply nested
5656
callbacks. With the basic control-flow out of the way, let's talk about the
5757
real `Future` trait and how it is different.
5858

59-
```rust
59+
```rust,ignore
6060
{{#include ../../examples/02_02_future_trait/src/lib.rs:real_future}}
6161
```
6262

6363
The first change you'll notice is that our `self` type is no longer `&mut self`,
64-
but has changed to `Pin<&mut Self>`. We'll talk more about pinning in [a later
64+
but has changed to `Pin<&mut Self>`. We'll talk more about pinning in [a later
6565
section][pinning], but for now know that it allows us to create futures that
6666
are immovable. Immovable objects can store pointers between their fields,
6767
e.g. `struct MyFut { a: i32, ptr_to_a: *const i32 }`. Pinning is necessary

src/02_execution/03_wakeups.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ thread to communicate that the timer has elapsed and the future should complete.
3434
We'll use a shared `Arc<Mutex<..>>` value to communicate between the thread and
3535
the future.
3636

37-
```rust
37+
```rust,ignore
3838
{{#include ../../examples/02_03_timer/src/lib.rs:timer_decl}}
3939
```
4040

4141
Now, let's actually write the `Future` implementation!
4242

43-
```rust
43+
```rust,ignore
4444
{{#include ../../examples/02_03_timer/src/lib.rs:future_for_timer}}
4545
```
4646

@@ -55,7 +55,7 @@ being polled.
5555

5656
Finally, we need the API to actually construct the timer and start the thread:
5757

58-
```rust
58+
```rust,ignore
5959
{{#include ../../examples/02_03_timer/src/lib.rs:timer_new}}
6060
```
6161

src/02_execution/04_executor.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ futures = "0.3"
3232

3333
Next, we need the following imports at the top of `src/main.rs`:
3434

35-
```rust
35+
```rust,ignore
3636
{{#include ../../examples/02_04_executor/src/lib.rs:imports}}
3737
```
3838

@@ -47,7 +47,7 @@ Tasks themselves are just futures that can reschedule themselves, so we'll
4747
store them as a future paired with a sender that the task can use to requeue
4848
itself.
4949

50-
```rust
50+
```rust,ignore
5151
{{#include ../../examples/02_04_executor/src/lib.rs:executor_decl}}
5252
```
5353

@@ -56,7 +56,7 @@ This method will take a future type, box it and put it in a FutureObj,
5656
and create a new `Arc<Task>` with it inside which can be enqueued onto the
5757
executor.
5858

59-
```rust
59+
```rust,ignore
6060
{{#include ../../examples/02_04_executor/src/lib.rs:spawn_fn}}
6161
```
6262

@@ -70,23 +70,23 @@ the `waker_ref` or `.into_waker()` functions to turn an `Arc<impl ArcWake>`
7070
into a `Waker`. Let's implement `ArcWake` for our tasks to allow them to be
7171
turned into `Waker`s and awoken:
7272

73-
```rust
73+
```rust,ignore
7474
{{#include ../../examples/02_04_executor/src/lib.rs:arcwake_for_task}}
7575
```
7676

7777
When a `Waker` is created from an `Arc<Task>`, calling `wake()` on it will
7878
cause a copy of the `Arc` to be sent onto the task channel. Our executor then
7979
needs to pick up the task and poll it. Let's implement that:
8080

81-
```rust
81+
```rust,ignore
8282
{{#include ../../examples/02_04_executor/src/lib.rs:executor_run}}
8383
```
8484

8585
Congratulations! We now have a working futures executor. We can even use it
8686
to run `async/.await` code and custom futures, such as the `TimerFuture` we
8787
wrote earlier:
8888

89-
```rust
89+
```rust,edition2018,ignore
9090
{{#include ../../examples/02_04_executor/src/lib.rs:main}}
9191
```
9292

src/02_execution/05_io.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
In the previous section on [The `Future` Trait], we discussed this example of
44
a future that performed an asynchronous read on a socket:
55

6-
```rust
6+
```rust,ignore
77
{{#include ../../examples/02_02_future_trait/src/lib.rs:socket_read}}
88
```
99

@@ -26,9 +26,9 @@ a thread to block on multiple asynchronous IO events, returning once one of
2626
the events completes. In practice, these APIs usually look something like
2727
this:
2828

29-
```rust
29+
```rust,ignore
3030
struct IoBlocker {
31-
...
31+
/* ... */
3232
}
3333
3434
struct Event {
@@ -41,7 +41,7 @@ struct Event {
4141
4242
impl IoBlocker {
4343
/// Create a new collection of asynchronous IO events to block on.
44-
fn new() -> Self { ... }
44+
fn new() -> Self { /* ... */ }
4545
4646
/// Express an interest in a particular IO event.
4747
fn add_io_event_interest(
@@ -54,10 +54,10 @@ impl IoBlocker {
5454
/// which an event should be triggered, paired with
5555
/// an ID to give to events that result from this interest.
5656
event: Event,
57-
) { ... }
57+
) { /* ... */ }
5858
5959
/// Block until one of the events occurs.
60-
fn block(&self) -> Event { ... }
60+
fn block(&self) -> Event { /* ... */ }
6161
}
6262
6363
let mut io_blocker = IoBlocker::new();
@@ -80,7 +80,7 @@ such as sockets that can configure callbacks to be run when a particular IO
8080
event occurs. In the case of our `SocketRead` example above, the
8181
`Socket::set_readable_callback` function might look like the following pseudocode:
8282

83-
```rust
83+
```rust,ignore
8484
impl Socket {
8585
fn set_readable_callback(&self, waker: Waker) {
8686
// `local_executor` is a reference to the local executor.

src/03_async_await/01_chapter.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ code to make progress while waiting on an operation to complete.
1212
There are two main ways to use `async`: `async fn` and `async` blocks.
1313
Each returns a value that implements the `Future` trait:
1414

15-
```rust
15+
```rust,edition2018,ignore
1616
{{#include ../../examples/03_01_async_await/src/lib.rs:async_fn_and_block_examples}}
1717
```
1818

@@ -29,7 +29,7 @@ Unlike traditional functions, `async fn`s which take references or other
2929
non-`'static` arguments return a `Future` which is bounded by the lifetime of
3030
the arguments:
3131

32-
```rust
32+
```rust,edition2018,ignore
3333
{{#include ../../examples/03_01_async_await/src/lib.rs:lifetimes_expanded}}
3434
```
3535

@@ -43,7 +43,7 @@ One common workaround for turning an `async fn` with references-as-arguments
4343
into a `'static` future is to bundle the arguments with the call to the
4444
`async fn` inside an `async` block:
4545

46-
```rust
46+
```rust,edition2018,ignore
4747
{{#include ../../examples/03_01_async_await/src/lib.rs:static_future_with_borrow}}
4848
```
4949

@@ -57,7 +57,7 @@ closures. An `async move` block will take ownership of the variables it
5757
references, allowing it to outlive the current scope, but giving up the ability
5858
to share those variables with other code:
5959

60-
```rust
60+
```rust,edition2018,ignore
6161
{{#include ../../examples/03_01_async_await/src/lib.rs:async_move_examples}}
6262
```
6363

src/04_pinning/01_chapter.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Pinning makes it possible to guarantee that an object won't ever be moved.
1212
To understand why this is necessary, we need to remember how `async`/`.await`
1313
works. Consider the following code:
1414

15-
```rust
16-
let fut_one = ...;
17-
let fut_two = ...;
15+
```rust,edition2018,ignore
16+
let fut_one = /* ... */;
17+
let fut_two = /* ... */;
1818
async move {
1919
fut_one.await;
2020
fut_two.await;
@@ -24,7 +24,7 @@ async move {
2424
Under the hood, this creates an anonymous type that implements `Future`,
2525
providing a `poll` method that looks something like this:
2626

27-
```rust
27+
```rust,ignore
2828
// The `Future` type generated by our `async { ... }` block
2929
struct AsyncFuture {
3030
fut_one: FutOne,
@@ -69,7 +69,7 @@ is able to successfully complete.
6969
However, what happens if we have an `async` block that uses references?
7070
For example:
7171

72-
```rust
72+
```rust,edition2018,ignore
7373
async {
7474
let mut x = [0; 128];
7575
let read_into_buf_fut = read_into_buf(&mut x);
@@ -80,7 +80,7 @@ async {
8080

8181
What struct does this compile down to?
8282

83-
```rust
83+
```rust,ignore
8484
struct ReadIntoBuf<'a> {
8585
buf: &'a mut [u8], // points to `x` below
8686
}
@@ -118,22 +118,22 @@ used as futures, and both implement `Unpin`.
118118

119119
For example:
120120

121-
```rust
121+
```rust,edition2018,ignore
122122
use pin_utils::pin_mut; // `pin_utils` is a handy crate available on crates.io
123123
124124
// A function which takes a `Future` that implements `Unpin`.
125-
fn execute_unpin_future(x: impl Future<Output = ()> + Unpin) { ... }
125+
fn execute_unpin_future(x: impl Future<Output = ()> + Unpin) { /* ... */ }
126126
127-
let fut = async { ... };
127+
let fut = async { /* ... */ };
128128
execute_unpin_future(fut); // Error: `fut` does not implement `Unpin` trait
129129
130130
// Pinning with `Box`:
131-
let fut = async { ... };
131+
let fut = async { /* ... */ };
132132
let fut = Box::pin(fut);
133133
execute_unpin_future(fut); // OK
134134
135135
// Pinning with `pin_mut!`:
136-
let fut = async { ... };
136+
let fut = async { /* ... */ };
137137
pin_mut!(fut);
138138
execute_unpin_future(fut); // OK
139139
```

src/05_streams/01_chapter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The `Stream` trait is similar to `Future` but can yield multiple values before
44
completing, similar to the `Iterator` trait from the standard library:
55

6-
```rust
6+
```rust,ignore
77
{{#include ../../examples/05_01_streams/src/lib.rs:stream_trait}}
88
```
99

@@ -12,6 +12,6 @@ the `futures` crate. It will yield `Some(val)` every time a value is sent
1212
from the `Sender` end, and will yield `None` once the `Sender` has been
1313
dropped and all pending messages have been received:
1414

15-
```rust
15+
```rust,edition2018,ignore
1616
{{#include ../../examples/05_01_streams/src/lib.rs:channels}}
1717
```

src/05_streams/02_iteration_and_concurrency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Unfortunately, `for` loops are not usable with `Stream`s, but for
99
imperative-style code, `while let` and the `next`/`try_next` functions can
1010
be used:
1111

12-
```rust
12+
```rust,edition2018,ignore
1313
{{#include ../../examples/05_02_iteration_and_concurrency/src/lib.rs:nexts}}
1414
```
1515

@@ -19,6 +19,6 @@ writing async code in the first place. To process multiple items from a stream
1919
concurrently, use the `for_each_concurrent` and `try_for_each_concurrent`
2020
methods:
2121

22-
```rust
22+
```rust,edition2018,ignore
2323
{{#include ../../examples/05_02_iteration_and_concurrency/src/lib.rs:try_for_each_concurrent}}
2424
```

src/06_multiple_futures/02_join.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ futures to complete while executing them all concurrently.
88
When performing multiple asynchronous operations, it's tempting to simply
99
`.await` them in a series:
1010

11-
```rust
11+
```rust,edition2018,ignore
1212
{{#include ../../examples/06_02_join/src/lib.rs:naiive}}
1313
```
1414

@@ -18,7 +18,7 @@ futures are ambiently run to completion, so two operations can be
1818
run concurrently by first calling each `async fn` to start the futures, and
1919
then awaiting them both:
2020

21-
```rust
21+
```rust,edition2018,ignore
2222
{{#include ../../examples/06_02_join/src/lib.rs:other_langs}}
2323
```
2424

@@ -28,7 +28,7 @@ This means that the two code snippets above will both run
2828
concurrently. To correctly run the two futures concurrently, use
2929
`futures::join!`:
3030

31-
```rust
31+
```rust,edition2018,ignore
3232
{{#include ../../examples/06_02_join/src/lib.rs:join}}
3333
```
3434

@@ -45,14 +45,14 @@ has returned an `Err`.
4545
Unlike `join!`, `try_join!` will complete immediately if one of the subfutures
4646
returns an error.
4747

48-
```rust
48+
```rust,edition2018,ignore
4949
{{#include ../../examples/06_02_join/src/lib.rs:try_join}}
5050
```
5151

5252
Note that the futures passed to `try_join!` must all have the same error type.
5353
Consider using the `.map_err(|e| ...)` and `.err_into()` functions from
5454
`futures::future::TryFutureExt` to consolidate the error types:
5555

56-
```rust
56+
```rust,edition2018,ignore
5757
{{#include ../../examples/06_02_join/src/lib.rs:try_join_map_err}}
5858
```

src/06_multiple_futures/03_select.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The `futures::select` macro runs multiple futures simultaneously, allowing
44
the user to respond as soon as any future completes.
55

6-
```rust
6+
```rust,edition2018
77
{{#include ../../examples/06_03_select/src/lib.rs:example}}
88
```
99

@@ -27,7 +27,7 @@ if none of the other futures are ready.
2727
being `select`ed over have completed and will no longer make progress.
2828
This is often handy when looping over a `select!`.
2929

30-
```rust
30+
```rust,edition2018
3131
{{#include ../../examples/06_03_select/src/lib.rs:default_and_complete}}
3232
```
3333

@@ -58,7 +58,7 @@ which implement this trait or have been wrapped using `.fuse()`
5858
will yield `FusedFuture` futures from their
5959
`.next()` / `.try_next()` combinators.
6060

61-
```rust
61+
```rust,edition2018
6262
{{#include ../../examples/06_03_select/src/lib.rs:fused_stream}}
6363
```
6464

@@ -75,7 +75,7 @@ Note the use of the `.select_next_some()` function. This can be
7575
used with `select` to only run the branch for `Some(_)` values
7676
returned from the stream, ignoring `None`s.
7777

78-
```rust
78+
```rust,edition2018
7979
{{#include ../../examples/06_03_select/src/lib.rs:fuse_terminated}}
8080
```
8181

@@ -85,6 +85,6 @@ to the one above, but will run each copy of `run_on_new_num_fut`
8585
to completion, rather than aborting them when a new one is created.
8686
It will also print out a value returned by `run_on_new_num_fut`.
8787

88-
```rust
88+
```rust,edition2018
8989
{{#include ../../examples/06_03_select/src/lib.rs:futures_unordered}}
9090
```

0 commit comments

Comments
 (0)