Skip to content
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

More edits to the async chapter #4033

Merged
merged 31 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a42f27b
Ch. 17: Fix up diagrams
chriskrycho Aug 24, 2024
f812ed0
Ch. 17§00: second round of edits
chriskrycho Aug 24, 2024
c648c0e
Use immutable borrow of `TcpStream` when creating `BufReader`
bin-wang Aug 30, 2024
ef4a518
cargo init usage suggestion
ficcialfaint Aug 31, 2024
1de14c8
Ch. 17: start restructuring chapter
chriskrycho Aug 24, 2024
6b6b450
Upgrade to Rust 1.81
chriskrycho Sep 10, 2024
589ce6b
Merge pull request #4031 from rust-lang/rust-1.81
chriskrycho Sep 11, 2024
299fd1f
Clarify Cargo.toml generation with `cargo init`.
chriskrycho Sep 11, 2024
28a2444
Merge pull request #4024 from bin-wang/remove-mut
chriskrycho Sep 11, 2024
e2b7246
Merge pull request #4025 from ficcialfaint/cargo-init
chriskrycho Sep 11, 2024
d5932d2
Update build instructions: include mdbook plugins
chriskrycho Sep 11, 2024
2b07207
Merge pull request #4032 from rust-lang/updated-build-instructions
chriskrycho Sep 12, 2024
c552952
Ch. 17: rename `trpl::block_on` to `trpl::run`
chriskrycho Aug 24, 2024
cd12a1e
Ch. 17: more edits for first three sections
chriskrycho Sep 10, 2024
487c81d
Merge `main` into `async-edits` (Rust 1.81 update)
chriskrycho Sep 11, 2024
9b13b95
Upgrade Ch. 17 listings for Rust 1.81
chriskrycho Sep 10, 2024
3cfdf2d
Ch. 17: rework 17.03 (and overall structure) from my own analysis
chriskrycho Sep 10, 2024
97902d5
Ch. 17: rework 17.04 with my own edits and analysis
chriskrycho Sep 11, 2024
68049c6
Ch. 17: rework 17.05 with my own edits and analysis
chriskrycho Sep 11, 2024
0d8da8b
Ch. 17: fold together 17.03 and 17.04
chriskrycho Sep 11, 2024
7da825f
Ch. 17: Make the new 17.05 actually work as a deep dive!
chriskrycho Sep 11, 2024
6bdf1b7
Merge `main` into `async-edits`
chriskrycho Sep 12, 2024
1d3517c
Ch. 17: integrate a number of the outstanding review comments
chriskrycho Sep 11, 2024
c4d02bf
Ch. 17: address the rest of James’ review comments 🎉
chriskrycho Sep 12, 2024
c35b7d9
Ch. 17: address most of the rest of Carol's outstanding comments
chriskrycho Sep 12, 2024
453247c
Ch. 17: address Tim and Carol's outstanding comments
chriskrycho Sep 13, 2024
ccafd06
Ch. 17: Fix some typos!
chriskrycho Sep 13, 2024
6f5773e
Remove duplicate integration test from root
chriskrycho Sep 16, 2024
cc5db97
Ch. 17: rewrite 17.01 with a better example
chriskrycho Sep 13, 2024
573a6ca
Ch. 17: fix mdbook test output
chriskrycho Sep 20, 2024
b265249
Ch. 17: Fix spelling and internal links
chriskrycho Sep 23, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.79 -c rust-docs
rustup default 1.79
rustup toolchain install 1.81 -c rust-docs
rustup default 1.81
- name: Install mdbook
run: |
mkdir bin
Expand Down Expand Up @@ -47,8 +47,8 @@ jobs:
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.79 -c rust-docs
rustup default 1.79
rustup toolchain install 1.81 -c rust-docs
rustup default 1.81
- name: Run `tools` package tests
run: |
cargo test
Expand Down
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ rust-lang/rust uses in [this file][rust-mdbook]. To get it:
$ cargo install mdbook --locked --version <version_num>
```

The book also uses two mdbook plugins which are part of this repository. If you
do not install them, you will see warnings when building and the output will not
look right, but you *will* still be able to build the book. To use the plugins,
you should run:

```bash
$ cargo install --locked --path packages/mdbook-trpl-listing
$ cargo install --locked --path packages/mdbook-trpl-note
```

## Building

To build the book, type:
Expand Down Expand Up @@ -63,7 +73,8 @@ $ start chrome.exe .\book\index.html # Windows (Cmd)
To run the tests:

```bash
$ mdbook test
$ cd packages/trpl
$ mdbook test --library-path packages/trpl/target/debug/deps
```

## Contributing
Expand Down
7 changes: 7 additions & 0 deletions ci/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ ebook
ebooks
Edsger
egular
ElementRef
else's
emoji
encodings
Expand Down Expand Up @@ -191,6 +192,8 @@ FrenchToast
FromIterator
FromResidual
frontend
FuturesUnordered
GetAwaitPoint
getrandom
getter
getters
Expand Down Expand Up @@ -248,6 +251,7 @@ internet
interoperate
IntoFuture
IntoIterator
intra
InvalidDigit
invariants
ioerror
Expand Down Expand Up @@ -295,6 +299,7 @@ lval
macOS
Matsakis
mathematic
mdbook
memoization
metadata
Metadata
Expand Down Expand Up @@ -370,6 +375,7 @@ OurError
OutlinePrint
overloadable
overread
PageTitleFuture
PanicPayload
parallelizable
param
Expand Down Expand Up @@ -521,6 +527,7 @@ TcpListener
TcpStream
templating
test's
TextAwaitPoint
TextField
That'd
there'd
Expand Down
23 changes: 14 additions & 9 deletions dot/trpl17-02.dot
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
digraph {
dpi = 300.0;

rankdir = "LR";
splines = false;
cluster = true;

node [shape = diamond;];


// The graphs end up with the correct order, i.e. Task 1 *above* Task 2, when
// this is first.
subgraph cluster_ColleagueB {
label = "Task 2";
B1 -> B2 -> B3;

B0 [style = invis;];
B3 -> B0 [style = invis;]
}

subgraph cluster_ColleagueA {
newrank = true;
label = "Task 1";
A1 -> A2 -> A3 -> A4;
}

subgraph cluster_ColleagueB {
label = "Task 2";
B1 -> B2 -> B3;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
$ cargo build
Downloading crates ...
Downloaded rand_core v0.6.2
Downloaded getrandom v0.2.2
Downloaded rand_chacha v0.3.0
Downloaded ppv-lite86 v0.2.10
Downloaded libc v0.2.86
Compiling libc v0.2.86
Compiling getrandom v0.2.2
Compiling cfg-if v1.0.0
Expand All @@ -18,7 +24,7 @@ error[E0308]: mismatched types
= note: expected reference `&String`
found reference `&{integer}`
note: method defined here
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/cmp.rs:840:8
--> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/cmp.rs:839:8

For more information about this error, try `rustc --explain E0308`.
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> src/main.rs:4:5
|
2 | let x = 5;
| -
| |
| first assignment to `x`
| help: consider making this binding mutable: `mut x`
| - first assignment to `x`
3 | println!("The value of x is: {x}");
4 | x = 6;
| ^^^^^ cannot assign twice to immutable variable
|
help: consider making this binding mutable
|
2 | let mut x = 5;
| +++

For more information about this error, try `rustc --explain E0384`.
error: could not compile `variables` (bin "variables") due to 1 previous error
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
= help: the trait `Add<Option<i8>>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
<i8 as Add<&i8>>
<i8 as Add>
`&'a i8` implements `Add<i8>`
`&i8` implements `Add<&i8>`
`i8` implements `Add<&i8>`
`i8` implements `Add`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `enums` (bin "enums") due to 1 previous error
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ error[E0004]: non-exhaustive patterns: `None` not covered
| ^ pattern `None` not covered
|
note: `Option<i32>` defined here
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:571:1
::: /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:575:5
--> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/option.rs:574:1
::: /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/option.rs:578:5
|
= note: not covered
= note: the matched value is of type `Option<i32>`
Expand Down
8 changes: 8 additions & 0 deletions listings/ch09-error-handling/listing-09-10/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
help: consider adding return type
|
3 ~ fn main() -> Result<(), Box<dyn std::error::Error>> {
4 | let greeting_file = File::open("hello.txt")?;
5 +
6 + Ok(())
7 + }
|

For more information about this error, try `rustc --explain E0277`.
error: could not compile `error-handling` (bin "error-handling") due to 1 previous error
2 changes: 1 addition & 1 deletion listings/ch13-functional-features/listing-13-04/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Locking 1 package to latest compatible version
Adding closure-example v0.1.0 (/Users/carolnichols/rust/book/tmp/listings/ch13-functional-features/listing-13-04)
Adding closure-example v0.1.0 (/Users/chris/dev/rust-lang/book/tmp/listings/ch13-functional-features/listing-13-04)
Compiling closure-example v0.1.0 (file:///projects/closure-example)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s
Running `target/debug/closure-example`
Expand Down
2 changes: 1 addition & 1 deletion listings/ch13-functional-features/listing-13-05/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ cargo run
Locking 1 package to latest compatible version
Adding closure-example v0.1.0 (/Users/carolnichols/rust/book/tmp/listings/ch13-functional-features/listing-13-05)
Adding closure-example v0.1.0 (/Users/chris/dev/rust-lang/book/tmp/listings/ch13-functional-features/listing-13-05)
Compiling closure-example v0.1.0 (file:///projects/closure-example)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s
Running `target/debug/closure-example`
Expand Down
2 changes: 1 addition & 1 deletion listings/ch15-smart-pointers/listing-15-21/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ help: consider changing this to be a mutable reference in the `impl` method and
|
2 ~ fn send(&mut self, msg: &str);
3 | }
...
...
56 | impl Messenger for MockMessenger {
57 ~ fn send(&mut self, message: &str) {
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ note: required because it's used within this closure
11 | let handle = thread::spawn(move || {
| ^^^^^^^
note: required by a bound in `spawn`
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/thread/mod.rs:691:1
--> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/mod.rs:688:1

For more information about this error, try `rustc --explain E0277`.
error: could not compile `shared-state` (bin "shared-state") due to 1 previous error
Loading