Skip to content

Commit fa312a3

Browse files
authored
Merge pull request #4211 from rust-lang/reformatted-src-with-dprint
chore: reformat src with dprint
2 parents 9b552dd + d4b0a0f commit fa312a3

8 files changed

+16
-11
lines changed

src/ch06-03-if-let.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ To make this common pattern nicer to express, Rust has `let`-`else`. The
107107
`let`-`else` syntax takes a pattern on the left side and an expression on the
108108
right, very similar to `if let`, but it does not have an `if` branch, only an
109109
`else` branch. If the pattern matches, it will bind the value from the pattern
110-
in the outer scope. If the pattern does *not* match, the program will flow into
110+
in the outer scope. If the pattern does _not_ match, the program will flow into
111111
the `else` arm, which must return from the function.
112112

113113
In Listing 6-9, you can see how Listing 6-8 looks when using `let`-`else` in

src/ch17-00-async-await.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ be nice if we could do something else while we are waiting for those
55
long-running processes to complete. Modern computers offer two techniques for
66
working on more than one operation at a time: parallelism and concurrency. Once
77
we start writing programs that involve parallel or concurrent operations,
8-
though, we quickly encounter new challenges inherent to *asynchronous
9-
programming*, where operations may not finish sequentially in the order they
8+
though, we quickly encounter new challenges inherent to _asynchronous
9+
programming_, where operations may not finish sequentially in the order they
1010
were started. This chapter builds on Chapter 16’s use of threads for parallelism
1111
and concurrency by introducing an alternative approach to asynchronous
1212
programming: Rust’s Futures, Streams, the `async` and `await` syntax that

src/ch17-01-futures-and-syntax.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ futures passed to it finishes first.
354354

355355
> Note: Under the hood, `race` is built on a more general function, `select`,
356356
> which you will encounter more often in real-world Rust code. A `select`
357-
> function can do a lot of things that the `trpl::race` function can’t, but it
357+
> function can do a lot of things that the `trpl::race` function can’t, but it
358358
> also has some additional complexity that we can skip over for now.
359359
360360
Either future can legitimately “win,” so it doesn’t make sense to return a

src/ch17-02-concurrency-with-async.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Applying Concurrency with Async
22

33
<!-- Old headings. Do not remove or links may break. -->
4+
45
<a id="concurrency-with-async"></a>
56

67
In this section, we’ll apply async to some of the same concurrency challenges
@@ -15,6 +16,7 @@ often have different behavior—and they nearly always have different performanc
1516
characteristics.
1617

1718
<!-- Old headings. Do not remove or links may break. -->
19+
1820
<a id="counting"></a>
1921

2022
### Creating a New Task with `spawn_task`
@@ -178,6 +180,7 @@ For an extra challenge, see if you can figure out what the output will be in
178180
each case _before_ running the code!
179181

180182
<!-- Old headings. Do not remove or links may break. -->
183+
181184
<a id="message-passing"></a>
182185

183186
### Counting Up on Two Tasks Using Message Passing

src/ch17-03-more-futures.md

+1
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ each other.
378378
But _how_ would you hand control back to the runtime in those cases?
379379

380380
<!-- Old headings. Do not remove or links may break. -->
381+
381382
<a id="yielding"></a>
382383

383384
### Yielding Control to the Runtime

src/ch17-04-streams.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Streams: Futures in Sequence
22

33
<!-- Old headings. Do not remove or links may break. -->
4-
<a id="streams"></a>
54

5+
<a id="streams"></a>
66

77
So far in this chapter, we’ve mostly stuck to individual futures. The one big
88
exception was the async channel we used. Recall how we used the receiver for our
@@ -122,7 +122,7 @@ we can do that _is_ unique to streams.
122122
### Composing Streams
123123

124124
Many concepts are naturally represented as streams: items becoming available in
125-
a queue, chunks of data being pulled incrementally from the filesystem when the
125+
a queue, chunks of data being pulled incrementally from the filesystem when the
126126
full data set is too large for the computer’s , or data arriving over the
127127
network over time. Because streams are futures, we can use them with any other
128128
kind of future and combine them in interesting ways. For example, we can batch
@@ -174,8 +174,6 @@ Again, we could do this with the regular `Receiver` API or even the regular
174174
timeout that applies to every item in the stream, and a delay on the items we
175175
emit, as shown in Listing 17-34.
176176

177-
178-
179177
<Listing number="17-34" caption="Using the `StreamExt::timeout` method to set a time limit on the items in a stream" file-name="src/main.rs">
180178

181179
```rust

src/ch17-05-traits-for-async.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## A Closer Look at the Traits for Async
22

33
<!-- Old headings. Do not remove or links may break. -->
4+
45
<a id="digging-into-the-traits-for-async"></a>
56

67
Throughout the chapter, we’ve used the `Future`, `Pin`, `Unpin`, `Stream`, and
@@ -12,6 +13,7 @@ details. In this section, we’ll dig in just enough to help in those scenarios,
1213
still leaving the _really_ deep dive for other documentation.
1314

1415
<!-- Old headings. Do not remove or links may break. -->
16+
1517
<a id="future"></a>
1618

1719
### The `Future` Trait
@@ -118,6 +120,7 @@ future it is responsible for, putting the future back to sleep when it is not
118120
yet ready.
119121

120122
<!-- Old headings. Do not remove or links may break. -->
123+
121124
<a id="pinning-and-the-pin-and-unpin-traits"></a>
122125

123126
### The `Pin` and `Unpin` Traits
@@ -210,7 +213,7 @@ enforce constraints on pointer usage.
210213

211214
Recalling that `await` is implemented in terms of calls to `poll` starts to
212215
explain the error message we saw earlier, but that was in terms of `Unpin`, not
213-
`Pin`. So how exactly does `Pin` relate to `Unpin`, and why does `Future` need
216+
`Pin`. So how exactly does `Pin` relate to `Unpin`, and why does `Future` need
214217
`self` to be in a `Pin` type to call `poll`?
215218

216219
Remember from earlier in this chapter a series of await points in a future get

src/ch21-03-graceful-shutdown-and-cleanup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ alternative approaches. They can make your code cleaner and less error-prone.
6767

6868
In this case, there is a better alternative: the `Vec::drain` method. It accepts
6969
a range parameter to specify which items to remove from the `Vec`, and returns
70-
an iterator of those items. Passing the `..` range syntax will remove *every*
70+
an iterator of those items. Passing the `..` range syntax will remove _every_
7171
value from the `Vec`.
7272

7373
So we need to update the `ThreadPool` `drop` implementation like this:
@@ -99,7 +99,7 @@ implementation and then a change in the `Worker` loop.
9999
First, we’ll change the `ThreadPool` `drop` implementation to explicitly drop
100100
the `sender` before waiting for the threads to finish. Listing 21-23 shows the
101101
changes to `ThreadPool` to explicitly drop `sender`. Unlike with the `workers`,
102-
here we *do* need to use an `Option` to be able to move `sender` out of
102+
here we _do_ need to use an `Option` to be able to move `sender` out of
103103
`ThreadPool` with `Option::take`.
104104

105105
<Listing number="21-23" file-name="src/lib.rs" caption="Explicitly drop `sender` before joining the worker threads">

0 commit comments

Comments
 (0)