diff --git a/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs old mode 100755 new mode 100644 index d44e290..b822b89 --- a/listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs +++ b/listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs @@ -25,7 +25,7 @@ fn main() { // ANCHOR_END: expect // ANCHOR: print_guess - println!("You guessed: {guess}"); + println!("You guessed: {}", guess); // ANCHOR_END: print_guess } // ANCHOR: all diff --git a/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock old mode 100755 new mode 100644 index edc2038..0fb52b3 --- a/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock +++ b/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock @@ -10,9 +10,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -28,15 +28,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.127" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "rand" @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] diff --git a/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-03/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt old mode 100755 new mode 100644 index 70a0c93..4a36350 --- a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt +++ b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt @@ -11,13 +11,14 @@ error[E0308]: mismatched types --> src/main.rs:22:21 | 22 | match guess.cmp(&secret_number) { - | --- ^^^^^^^^^^^^^^ expected struct `String`, found integer + | --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected reference `&String` found reference `&{integer}` -note: associated function defined here +note: method defined here + --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/cmp.rs:836:8 For more information about this error, try `rustc --explain E0308`. -error: could not compile `guessing_game` due to previous error +error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-05/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.lock b/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.toml b/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/listing-02-06/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.lock b/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.toml b/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt b/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt old mode 100755 new mode 100644 index 2724c14..33409e3 --- a/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt +++ b/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 1.50s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.50s Running `target/debug/guessing_game` Hello, world! diff --git a/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/src/main.rs b/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.lock b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.toml b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt old mode 100755 new mode 100644 index 8095bbd..417d4e3 --- a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt +++ b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt @@ -4,10 +4,14 @@ warning: unused `Result` that must be used --> src/main.rs:10:5 | 10 | io::stdin().read_line(&mut guess); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled + = note: `#[warn(unused_must_use)]` on by default +help: use `let _ = ...` to ignore the resulting value + | +10 | let _ = io::stdin().read_line(&mut guess); + | +++++++ warning: `guessing_game` (bin "guessing_game") generated 1 warning - Finished dev [unoptimized + debuginfo] target(s) in 0.59s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.59s diff --git a/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/src/main.rs b/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.lock b/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.toml b/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/src/main.rs b/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.lock b/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.toml b/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-04-looping/src/main.rs b/listings/ch02-guessing-game-tutorial/no-listing-04-looping/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.lock b/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.toml b/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/src/main.rs b/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-01/Cargo.lock b/listings/ch03-common-programming-concepts/listing-03-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-01/Cargo.toml b/listings/ch03-common-programming-concepts/listing-03-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-01/src/main.rs b/listings/ch03-common-programming-concepts/listing-03-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-02/Cargo.lock b/listings/ch03-common-programming-concepts/listing-03-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-02/Cargo.toml b/listings/ch03-common-programming-concepts/listing-03-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-02/output.txt b/listings/ch03-common-programming-concepts/listing-03-02/output.txt old mode 100755 new mode 100644 index 3eb8d10..3b0deae --- a/listings/ch03-common-programming-concepts/listing-03-02/output.txt +++ b/listings/ch03-common-programming-concepts/listing-03-02/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.30s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s Running `target/debug/branches` The value of number is: 5 diff --git a/listings/ch03-common-programming-concepts/listing-03-02/src/main.rs b/listings/ch03-common-programming-concepts/listing-03-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-03/Cargo.lock b/listings/ch03-common-programming-concepts/listing-03-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-03/Cargo.toml b/listings/ch03-common-programming-concepts/listing-03-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-03/src/main.rs b/listings/ch03-common-programming-concepts/listing-03-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-04/Cargo.lock b/listings/ch03-common-programming-concepts/listing-03-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-04/Cargo.toml b/listings/ch03-common-programming-concepts/listing-03-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-04/output.txt b/listings/ch03-common-programming-concepts/listing-03-04/output.txt old mode 100755 new mode 100644 index 35c0f80..82408ac --- a/listings/ch03-common-programming-concepts/listing-03-04/output.txt +++ b/listings/ch03-common-programming-concepts/listing-03-04/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling loops v0.1.0 (file:///projects/loops) - Finished dev [unoptimized + debuginfo] target(s) in 0.32s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s Running `target/debug/loops` the value is: 10 the value is: 20 diff --git a/listings/ch03-common-programming-concepts/listing-03-04/src/main.rs b/listings/ch03-common-programming-concepts/listing-03-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-05/Cargo.lock b/listings/ch03-common-programming-concepts/listing-03-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-05/Cargo.toml b/listings/ch03-common-programming-concepts/listing-03-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/listing-03-05/src/main.rs b/listings/ch03-common-programming-concepts/listing-03-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt old mode 100755 new mode 100644 index ed87cb2..73ca9d6 --- a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt @@ -13,4 +13,4 @@ error[E0384]: cannot assign twice to immutable variable `x` | ^^^^^ cannot assign twice to immutable variable For more information about this error, try `rustc --explain E0384`. -error: could not compile `variables` due to previous error +error: could not compile `variables` (bin "variables") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt b/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt old mode 100755 new mode 100644 index 8ed6598..ed0c0c3 --- a/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling variables v0.1.0 (file:///projects/variables) - Finished dev [unoptimized + debuginfo] target(s) in 0.30s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s Running `target/debug/variables` The value of x is: 5 The value of x is: 6 diff --git a/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-03-shadowing/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-03-shadowing/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-03-shadowing/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-03-shadowing/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt b/listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt old mode 100755 new mode 100644 index f310e9f..6ff531b --- a/listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling variables v0.1.0 (file:///projects/variables) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s Running `target/debug/variables` The value of x in the inner scope is: 12 The value of x is: 6 diff --git a/listings/ch03-common-programming-concepts/no-listing-03-shadowing/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-03-shadowing/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-04-shadowing-can-change-types/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt old mode 100755 new mode 100644 index 31a07ef..578a1f4 --- a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt @@ -9,4 +9,4 @@ error[E0308]: mismatched types | ^^^^^^^^^^^^ expected `&str`, found `usize` For more information about this error, try `rustc --explain E0308`. -error: could not compile `variables` due to previous error +error: could not compile `variables` (bin "variables") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-06-floating-point/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-06-floating-point/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-06-floating-point/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-06-floating-point/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-06-floating-point/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-06-floating-point/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-08-boolean/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-08-boolean/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-08-boolean/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-08-boolean/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-08-boolean/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-08-boolean/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-09-char/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-09-char/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-09-char/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-09-char/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-09-char/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-09-char/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-10-tuples/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-10-tuples/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-10-tuples/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-10-tuples/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-10-tuples/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-10-tuples/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-11-destructuring-tuples/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-12-tuple-indexing/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-13-arrays/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-13-arrays/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-13-arrays/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-13-arrays/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-13-arrays/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-13-arrays/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-14-array-indexing/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-16-functions/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-16-functions/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-16-functions/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-16-functions/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-16-functions/output.txt b/listings/ch03-common-programming-concepts/no-listing-16-functions/output.txt old mode 100755 new mode 100644 index 723fad3..898cf5f --- a/listings/ch03-common-programming-concepts/no-listing-16-functions/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-16-functions/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.28s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s Running `target/debug/functions` Hello, world! Another function. diff --git a/listings/ch03-common-programming-concepts/no-listing-16-functions/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-16-functions/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/output.txt b/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/output.txt old mode 100755 new mode 100644 index 546bbc0..377f728 --- a/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 1.21s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.21s Running `target/debug/functions` The value of x is: 5 diff --git a/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-17-functions-with-parameters/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/output.txt b/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/output.txt old mode 100755 new mode 100644 index 6210234..91e71c1 --- a/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s Running `target/debug/functions` The measurement is: 5h diff --git a/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt old mode 100755 new mode 100644 index 6ae56e0..504fdd6 --- a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt @@ -5,22 +5,8 @@ error: expected expression, found `let` statement | 2 | let x = (let y = 6); | ^^^ - -error: expected expression, found statement (`let`) - --> src/main.rs:2:14 | -2 | let x = (let y = 6); - | ^^^^^^^^^ - | - = note: variable declaration using `let` is a statement - -error[E0658]: `let` expressions in this position are unstable - --> src/main.rs:2:14 - | -2 | let x = (let y = 6); - | ^^^^^^^^^ - | - = note: see issue #53667 for more information + = note: only supported directly in conditions of `if` and `while` expressions warning: unnecessary parentheses around assigned value --> src/main.rs:2:13 @@ -35,6 +21,5 @@ help: remove these parentheses 2 + let x = let y = 6; | -For more information about this error, try `rustc --explain E0658`. warning: `functions` (bin "functions") generated 1 warning -error: could not compile `functions` due to 3 previous errors; 1 warning emitted +error: could not compile `functions` (bin "functions") due to 1 previous error; 1 warning emitted diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/rustfmt-ignore b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-20-blocks-are-expressions/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/output.txt b/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/output.txt old mode 100755 new mode 100644 index a457e33..e66e4b9 --- a/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.30s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s Running `target/debug/functions` The value of x is: 5 diff --git a/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-21-function-return-values/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt old mode 100755 new mode 100644 index c0484ea..18fdfd1 --- a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt @@ -8,7 +8,7 @@ error[E0308]: mismatched types | | | implicitly returns `()` as its body has no tail or `return` expression 8 | x + 1; - | - help: remove this semicolon + | - help: remove this semicolon to return this value For more information about this error, try `rustc --explain E0308`. -error: could not compile `functions` due to previous error +error: could not compile `functions` (bin "functions") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-24-comments-end-of-line/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-25-comments-above-line/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-26-if-true/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-26-if-true/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-26-if-true/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-26-if-true/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-26-if-true/output.txt b/listings/ch03-common-programming-concepts/no-listing-26-if-true/output.txt old mode 100755 new mode 100644 index 3d8c7dc..d39b3b5 --- a/listings/ch03-common-programming-concepts/no-listing-26-if-true/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-26-if-true/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s Running `target/debug/branches` condition was true diff --git a/listings/ch03-common-programming-concepts/no-listing-26-if-true/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-26-if-true/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-27-if-false/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-27-if-false/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-27-if-false/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-27-if-false/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-27-if-false/output.txt b/listings/ch03-common-programming-concepts/no-listing-27-if-false/output.txt old mode 100755 new mode 100644 index e40da96..3aa1e1c --- a/listings/ch03-common-programming-concepts/no-listing-27-if-false/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-27-if-false/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s Running `target/debug/branches` condition was false diff --git a/listings/ch03-common-programming-concepts/no-listing-27-if-false/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-27-if-false/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt old mode 100755 new mode 100644 index 735bfe7..c9c0b0c --- a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt @@ -7,4 +7,4 @@ error[E0308]: mismatched types | ^^^^^^ expected `bool`, found integer For more information about this error, try `rustc --explain E0308`. -error: could not compile `branches` due to previous error +error: could not compile `branches` (bin "branches") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-29-if-not-equal-0/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-30-else-if/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-30-else-if/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-30-else-if/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-30-else-if/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-30-else-if/output.txt b/listings/ch03-common-programming-concepts/no-listing-30-else-if/output.txt old mode 100755 new mode 100644 index b218941..d519524 --- a/listings/ch03-common-programming-concepts/no-listing-30-else-if/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-30-else-if/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s Running `target/debug/branches` number is divisible by 3 diff --git a/listings/ch03-common-programming-concepts/no-listing-30-else-if/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-30-else-if/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt old mode 100755 new mode 100644 index e922acd..7fb857f --- a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt @@ -9,4 +9,4 @@ error[E0308]: `if` and `else` have incompatible types | expected because of this For more information about this error, try `rustc --explain E0308`. -error: could not compile `branches` due to previous error +error: could not compile `branches` (bin "branches") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt b/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt old mode 100755 new mode 100644 index d4d322f..4977b2b --- a/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling loops v0.1.0 (file:///projects/loops) - Finished dev [unoptimized + debuginfo] target(s) in 0.58s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s Running `target/debug/loops` count = 0 remaining = 10 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-loop/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-32-loop/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-loop/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-32-loop/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-32-loop/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-32-loop/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-33-return-value-from-loop/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-34-for-range/Cargo.lock b/listings/ch03-common-programming-concepts/no-listing-34-for-range/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-34-for-range/Cargo.toml b/listings/ch03-common-programming-concepts/no-listing-34-for-range/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/no-listing-34-for-range/src/main.rs b/listings/ch03-common-programming-concepts/no-listing-34-for-range/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/Cargo.lock b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/Cargo.toml b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt old mode 100755 new mode 100644 index 8a11ccc..ee6a979 --- a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt +++ b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt @@ -1,15 +1,16 @@ $ cargo build Compiling no_type_annotations v0.1.0 (file:///projects/no_type_annotations) -error[E0282]: type annotations needed +error[E0284]: type annotations needed --> src/main.rs:2:9 | 2 | let guess = "42".parse().expect("Not a number!"); - | ^^^^^ + | ^^^^^ ----- type must be known at this point | + = note: cannot satisfy `<_ as FromStr>::Err == _` help: consider giving `guess` an explicit type | -2 | let guess: _ = "42".parse().expect("Not a number!"); - | +++ +2 | let guess: /* Type */ = "42".parse().expect("Not a number!"); + | ++++++++++++ -For more information about this error, try `rustc --explain E0282`. -error: could not compile `no_type_annotations` due to previous error +For more information about this error, try `rustc --explain E0284`. +error: could not compile `no_type_annotations` (bin "no_type_annotations") due to 1 previous error diff --git a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/src/main.rs b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-01/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-01/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-01/rustfmt-ignore b/listings/ch04-understanding-ownership/listing-04-01/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-01/src/main.rs b/listings/ch04-understanding-ownership/listing-04-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-02/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-02/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-02/src/main.rs b/listings/ch04-understanding-ownership/listing-04-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-03/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-03/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-03/rustfmt-ignore b/listings/ch04-understanding-ownership/listing-04-03/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-03/src/main.rs b/listings/ch04-understanding-ownership/listing-04-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-04/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-04/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-04/rustfmt-ignore b/listings/ch04-understanding-ownership/listing-04-04/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-04/src/main.rs b/listings/ch04-understanding-ownership/listing-04-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-05/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-05/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-05/src/main.rs b/listings/ch04-understanding-ownership/listing-04-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-06/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-06/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-06/output.txt b/listings/ch04-understanding-ownership/listing-04-06/output.txt old mode 100755 new mode 100644 index 1176f4e..c78cd5d --- a/listings/ch04-understanding-ownership/listing-04-06/output.txt +++ b/listings/ch04-understanding-ownership/listing-04-06/output.txt @@ -3,10 +3,13 @@ $ cargo run error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference --> src/main.rs:8:5 | -7 | fn change(some_string: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut String` 8 | some_string.push_str(", world"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +7 | fn change(some_string: &mut String) { + | +++ For more information about this error, try `rustc --explain E0596`. -error: could not compile `ownership` due to previous error +error: could not compile `ownership` (bin "ownership") due to 1 previous error diff --git a/listings/ch04-understanding-ownership/listing-04-06/src/main.rs b/listings/ch04-understanding-ownership/listing-04-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-07/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-07/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-07/src/main.rs b/listings/ch04-understanding-ownership/listing-04-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-08/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-08/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-08/src/main.rs b/listings/ch04-understanding-ownership/listing-04-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-09/Cargo.lock b/listings/ch04-understanding-ownership/listing-04-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-09/Cargo.toml b/listings/ch04-understanding-ownership/listing-04-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/listing-04-09/src/main.rs b/listings/ch04-understanding-ownership/listing-04-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/src/main.rs b/listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-02-string-scope/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-02-string-scope/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-02-string-scope/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-02-string-scope/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-02-string-scope/rustfmt-ignore b/listings/ch04-understanding-ownership/no-listing-02-string-scope/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-02-string-scope/src/main.rs b/listings/ch04-understanding-ownership/no-listing-02-string-scope/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-03-string-move/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-03-string-move/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-03-string-move/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-03-string-move/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-03-string-move/src/main.rs b/listings/ch04-understanding-ownership/no-listing-03-string-move/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt old mode 100755 new mode 100644 index 05987f7..73e6115 --- a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt @@ -1,17 +1,21 @@ $ cargo run Compiling ownership v0.1.0 (file:///projects/ownership) error[E0382]: borrow of moved value: `s1` - --> src/main.rs:5:28 + --> src/main.rs:5:15 | 2 | let s1 = String::from("hello"); | -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait 3 | let s2 = s1; | -- value moved here 4 | -5 | println!("{}, world!", s1); - | ^^ value borrowed here after move +5 | println!("{s1}, world!"); + | ^^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +3 | let s2 = s1.clone(); + | ++++++++ For more information about this error, try `rustc --explain E0382`. -error: could not compile `ownership` due to previous error +error: could not compile `ownership` (bin "ownership") due to 1 previous error diff --git a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs old mode 100755 new mode 100644 index d0b9f18..e35f6d8 --- a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs +++ b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs @@ -3,6 +3,6 @@ fn main() { let s1 = String::from("hello"); let s2 = s1; - println!("{}, world!", s1); + println!("{s1}, world!"); // ANCHOR_END: here } diff --git a/listings/ch04-understanding-ownership/no-listing-05-clone/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-05-clone/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-05-clone/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-05-clone/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs b/listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs old mode 100755 new mode 100644 index 4e61cc1..0b65e5f --- a/listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs +++ b/listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs @@ -3,6 +3,6 @@ fn main() { let s1 = String::from("hello"); let s2 = s1.clone(); - println!("s1 = {}, s2 = {}", s1, s2); + println!("s1 = {s1}, s2 = {s2}"); // ANCHOR_END: here } diff --git a/listings/ch04-understanding-ownership/no-listing-06-copy/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-06-copy/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-06-copy/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-06-copy/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs b/listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs old mode 100755 new mode 100644 index 63a1fae..b6fd244 --- a/listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs +++ b/listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs @@ -3,6 +3,6 @@ fn main() { let x = 5; let y = x; - println!("x = {}, y = {}", x, y); + println!("x = {x}, y = {y}"); // ANCHOR_END: here } diff --git a/listings/ch04-understanding-ownership/no-listing-07-reference/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-07-reference/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-07-reference/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-07-reference/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs b/listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs old mode 100755 new mode 100644 index fd32a5f..6f6d5fb --- a/listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs +++ b/listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs @@ -6,7 +6,7 @@ fn main() { let len = calculate_length(&s1); // ANCHOR_END: here - println!("The length of '{}' is {}.", s1, len); + println!("The length of '{s1}' is {len}."); } fn calculate_length(s: &String) -> usize { diff --git a/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/rustfmt-ignore b/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/src/main.rs b/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/src/main.rs b/listings/ch04-understanding-ownership/no-listing-09-fixes-listing-04-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt old mode 100755 new mode 100644 index 8820d2d..97be4a2 --- a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt @@ -12,4 +12,4 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time | -- first borrow later used here For more information about this error, try `rustc --explain E0499`. -error: could not compile `ownership` due to previous error +error: could not compile `ownership` (bin "ownership") due to 1 previous error diff --git a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/src/main.rs b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/src/main.rs b/listings/ch04-understanding-ownership/no-listing-11-muts-in-separate-scopes/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt old mode 100755 new mode 100644 index d1e9db2..4548823 --- a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt @@ -13,4 +13,4 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta | -- immutable borrow later used here For more information about this error, try `rustc --explain E0502`. -error: could not compile `ownership` due to previous error +error: could not compile `ownership` (bin "ownership") due to 1 previous error diff --git a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/src/main.rs b/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt old mode 100755 new mode 100644 index b466a3d..0339433 --- a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt @@ -7,10 +7,22 @@ error[E0106]: missing lifetime specifier | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | 5 | fn dangle() -> &'static String { | +++++++ +help: instead, you are more likely to want to return an owned value + | +5 - fn dangle() -> &String { +5 + fn dangle() -> String { + | -For more information about this error, try `rustc --explain E0106`. -error: could not compile `ownership` due to previous error +error[E0515]: cannot return reference to local variable `s` + --> src/main.rs:8:5 + | +8 | &s + | ^^ returns a reference to data owned by the current function + +Some errors have detailed explanations: E0106, E0515. +For more information about an error, try `rustc --explain E0106`. +error: could not compile `ownership` (bin "ownership") due to 2 previous errors diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/src/main.rs b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/rustfmt-ignore b/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/src/main.rs b/listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-16-no-dangle/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-16-no-dangle/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-16-no-dangle/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-16-no-dangle/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-16-no-dangle/src/main.rs b/listings/ch04-understanding-ownership/no-listing-16-no-dangle/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-17-slice/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-17-slice/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-17-slice/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-17-slice/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-17-slice/src/main.rs b/listings/ch04-understanding-ownership/no-listing-17-slice/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/src/main.rs b/listings/ch04-understanding-ownership/no-listing-18-first-word-slice/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-19-slice-error/Cargo.lock b/listings/ch04-understanding-ownership/no-listing-19-slice-error/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-19-slice-error/Cargo.toml b/listings/ch04-understanding-ownership/no-listing-19-slice-error/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt b/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt old mode 100755 new mode 100644 index ab0c41f..c29ddf5 --- a/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt @@ -9,8 +9,8 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta 18 | s.clear(); // error! | ^^^^^^^^^ mutable borrow occurs here 19 | -20 | println!("the first word is: {}", word); - | ---- immutable borrow later used here +20 | println!("the first word is: {word}"); + | ------ immutable borrow later used here For more information about this error, try `rustc --explain E0502`. -error: could not compile `ownership` due to previous error +error: could not compile `ownership` (bin "ownership") due to 1 previous error diff --git a/listings/ch04-understanding-ownership/no-listing-19-slice-error/src/main.rs b/listings/ch04-understanding-ownership/no-listing-19-slice-error/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-01/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-01/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-01/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-02/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-02/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-02/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-03/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-03/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-03/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-04/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-04/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-04/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-05/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-05/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-05/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-06/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-06/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-06/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-07/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-07/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-07/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-08/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-08/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-08/output.txt b/listings/ch05-using-structs-to-structure-related-data/listing-05-08/output.txt old mode 100755 new mode 100644 index c44b582..79b8307 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-08/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-08/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling rectangles v0.1.0 (file:///projects/rectangles) - Finished dev [unoptimized + debuginfo] target(s) in 0.42s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.42s Running `target/debug/rectangles` The area of the rectangle is 1500 square pixels. diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-08/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-09/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-09/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-09/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-10/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-10/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-10/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt old mode 100755 new mode 100644 index 7d3bfcd..ee16972 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt @@ -11,4 +11,4 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. -error: could not compile `rectangles` due to previous error +error: could not compile `rectangles` (bin "rectangles") due to 1 previous error diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/output.txt b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/output.txt old mode 100755 new mode 100644 index c37be6b..0c810b1 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling rectangles v0.1.0 (file:///projects/rectangles) - Finished dev [unoptimized + debuginfo] target(s) in 0.48s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `target/debug/rectangles` rect1 is Rectangle { width: 30, height: 50 } diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/src/main.rs old mode 100755 new mode 100644 index 2ffc4b8..67e0b92 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-12/src/main.rs +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-12/src/main.rs @@ -10,5 +10,5 @@ fn main() { height: 50, }; - println!("rect1 is {:?}", rect1); + println!("rect1 is {rect1:?}"); } diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-13/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-13/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-13/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-14/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-14/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-14/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-15/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-15/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-15/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-16/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/listing-05-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-16/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/listing-05-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-16/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/listing-05-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-01-tuple-structs/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt old mode 100755 new mode 100644 index e28da59..5f9344c --- a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt @@ -28,4 +28,4 @@ help: consider introducing a named lifetime parameter | For more information about this error, try `rustc --explain E0106`. -error: could not compile `structs` due to 2 previous errors +error: could not compile `structs` (bin "structs") due to 2 previous errors diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-04-unit-like-structs/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt b/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt old mode 100755 new mode 100644 index 2685859..1c1f07d --- a/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt @@ -1,9 +1,9 @@ $ cargo run Compiling rectangles v0.1.0 (file:///projects/rectangles) - Finished dev [unoptimized + debuginfo] target(s) in 0.61s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s Running `target/debug/rectangles` -[src/main.rs:10] 30 * scale = 60 -[src/main.rs:14] &rect1 = Rectangle { +[src/main.rs:10:16] 30 * scale = 60 +[src/main.rs:14:5] &rect1 = Rectangle { width: 60, height: 50, } diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/no-listing-06-method-field-interaction/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt old mode 100755 new mode 100644 index 58cb842..71de1f7 --- a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt @@ -11,8 +11,9 @@ error[E0277]: `Rectangle` doesn't implement `Debug` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Rectangle` with `#[derive(Debug)]` | -1 | #[derive(Debug)] +1 + #[derive(Debug)] +2 | struct Rectangle { | For more information about this error, try `rustc --explain E0277`. -error: could not compile `rectangles` due to previous error +error: could not compile `rectangles` (bin "rectangles") due to 1 previous error diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/Cargo.lock b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/Cargo.toml b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/output.txt b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/output.txt old mode 100755 new mode 100644 index db6deed..4a6c5a9 --- a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling rectangles v0.1.0 (file:///projects/rectangles) - Finished dev [unoptimized + debuginfo] target(s) in 0.48s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `target/debug/rectangles` rect1 is Rectangle { width: 30, diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/src/main.rs b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/src/main.rs old mode 100755 new mode 100644 index 84e32ae..f763b50 --- a/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/src/main.rs +++ b/listings/ch05-using-structs-to-structure-related-data/output-only-02-pretty-debug/src/main.rs @@ -10,5 +10,5 @@ fn main() { height: 50, }; - println!("rect1 is {:#?}", rect1); + println!("rect1 is {rect1:#?}"); } diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-01/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-01/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-01/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-02/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-02/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-02/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-03/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-03/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-03/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-04/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-04/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-04/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-05/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-05/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-06/Cargo.lock b/listings/ch06-enums-and-pattern-matching/listing-06-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-06/Cargo.toml b/listings/ch06-enums-and-pattern-matching/listing-06-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs old mode 100755 new mode 100644 index dc2bffb..0a03751 --- a/listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs +++ b/listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs @@ -2,7 +2,7 @@ fn main() { // ANCHOR: here let config_max = Some(3u8); match config_max { - Some(max) => println!("The maximum is configured to be {}", max), + Some(max) => println!("The maximum is configured to be {max}"), _ => (), } // ANCHOR_END: here diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-01-defining-enums/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-02-enum-with-data/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-03-variants-with-different-data/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-05-methods-on-enums/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-06-option-examples/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt old mode 100755 new mode 100644 index d4a040e..fa202e6 --- a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt +++ b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt @@ -8,15 +8,10 @@ error[E0277]: cannot add `Option` to `i8` | = help: the trait `Add>` is not implemented for `i8` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> + + > <&'a i8 as Add> - <&'a isize as Add> - and 48 others + <&i8 as Add<&i8>> For more information about this error, try `rustc --explain E0277`. -error: could not compile `enums` due to previous error +error: could not compile `enums` (bin "enums") due to 1 previous error diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-08-match-arm-multiple-lines/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/src/main.rs old mode 100755 new mode 100644 index a4d500c..298215d --- a/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/src/main.rs +++ b/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/src/main.rs @@ -19,7 +19,7 @@ fn value_in_cents(coin: Coin) -> u8 { Coin::Nickel => 5, Coin::Dime => 10, Coin::Quarter(state) => { - println!("State quarter from {:?}!", state); + println!("State quarter from {state:?}!"); 25 } } diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt old mode 100755 new mode 100644 index bec7284..7d9a661 --- a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt +++ b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt @@ -7,6 +7,10 @@ error[E0004]: non-exhaustive patterns: `None` not covered | ^ pattern `None` not covered | note: `Option` defined here + --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:572:1 + ::: /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:576:5 + | + = note: not covered = note: the matched value is of type `Option` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | @@ -15,4 +19,4 @@ help: ensure that all possible cases are being handled by adding a match arm wit | For more information about this error, try `rustc --explain E0004`. -error: could not compile `enums` due to previous error +error: could not compile `enums` (bin "enums") due to 1 previous error diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/src/main.rs old mode 100755 new mode 100644 index 735086d..7d7254e --- a/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/src/main.rs +++ b/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/src/main.rs @@ -2,7 +2,7 @@ fn main() { // ANCHOR: here let config_max = Some(3u8); if let Some(max) = config_max { - println!("The maximum is configured to be {}", max); + println!("The maximum is configured to be {max}"); } // ANCHOR_END: here } diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/src/main.rs old mode 100755 new mode 100644 index 12c4c0f..d0d7d80 --- a/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/src/main.rs +++ b/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/src/main.rs @@ -17,7 +17,7 @@ fn main() { // ANCHOR: here let mut count = 0; match coin { - Coin::Quarter(state) => println!("State quarter from {:?}!", state), + Coin::Quarter(state) => println!("State quarter from {state:?}!"), _ => count += 1, } // ANCHOR_END: here diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs old mode 100755 new mode 100644 index ba7eda2..3bb3630 --- a/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs +++ b/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs @@ -17,7 +17,7 @@ fn main() { // ANCHOR: here let mut count = 0; if let Coin::Quarter(state) = coin { - println!("State quarter from {:?}!", state); + println!("State quarter from {state:?}!"); } else { count += 1; } diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-15-binding-catchall/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-16-underscore-catchall/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/Cargo.lock b/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/Cargo.toml b/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-17-underscore-unit/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-01/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-01/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-03/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-03/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-03/output.txt b/listings/ch07-managing-growing-projects/listing-07-03/output.txt old mode 100755 new mode 100644 index 481dcb3..2d06c7f --- a/listings/ch07-managing-growing-projects/listing-07-03/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-03/output.txt @@ -4,7 +4,9 @@ error[E0603]: module `hosting` is private --> src/lib.rs:9:28 | 9 | crate::front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ private module + | ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported + | | + | private module | note: the module `hosting` is defined here --> src/lib.rs:2:5 @@ -16,7 +18,9 @@ error[E0603]: module `hosting` is private --> src/lib.rs:12:21 | 12 | front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ private module + | ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported + | | + | private module | note: the module `hosting` is defined here --> src/lib.rs:2:5 @@ -25,4 +29,4 @@ note: the module `hosting` is defined here | ^^^^^^^^^^^ For more information about this error, try `rustc --explain E0603`. -error: could not compile `restaurant` due to 2 previous errors +error: could not compile `restaurant` (lib) due to 2 previous errors diff --git a/listings/ch07-managing-growing-projects/listing-07-03/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-03/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-05/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-05/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-05/output.txt b/listings/ch07-managing-growing-projects/listing-07-05/output.txt old mode 100755 new mode 100644 index 63eb89a..98d8d6e --- a/listings/ch07-managing-growing-projects/listing-07-05/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-05/output.txt @@ -25,4 +25,4 @@ note: the function `add_to_waitlist` is defined here | ^^^^^^^^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0603`. -error: could not compile `restaurant` due to 2 previous errors +error: could not compile `restaurant` (lib) due to 2 previous errors diff --git a/listings/ch07-managing-growing-projects/listing-07-05/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-05/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-07/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-07/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-08/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-08/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-09/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-09/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-09/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-09/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-10/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-10/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-10/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-10/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-11/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-11/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-12/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-12/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-12/output.txt b/listings/ch07-managing-growing-projects/listing-07-12/output.txt old mode 100755 new mode 100644 index 39b6505..0eda253 --- a/listings/ch07-managing-growing-projects/listing-07-12/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-12/output.txt @@ -5,6 +5,11 @@ error[E0433]: failed to resolve: use of undeclared crate or module `hosting` | 11 | hosting::add_to_waitlist(); | ^^^^^^^ use of undeclared crate or module `hosting` + | +help: consider importing this module through its public re-export + | +10 + use crate::hosting; + | warning: unused import: `crate::front_of_house::hosting` --> src/lib.rs:7:5 @@ -16,4 +21,4 @@ warning: unused import: `crate::front_of_house::hosting` For more information about this error, try `rustc --explain E0433`. warning: `restaurant` (lib) generated 1 warning -error: could not compile `restaurant` due to previous error; 1 warning emitted +error: could not compile `restaurant` (lib) due to 1 previous error; 1 warning emitted diff --git a/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-13/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-13/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-14/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-14/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-14/src/main.rs b/listings/ch07-managing-growing-projects/listing-07-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-15/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-15/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-15/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-16/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-16/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-16/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-16/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-17/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-17/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-18/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-18/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-18/src/main.rs b/listings/ch07-managing-growing-projects/listing-07-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-19/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-19/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-19/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-19/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-20/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-20/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-20/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-21-and-22/Cargo.lock b/listings/ch07-managing-growing-projects/listing-07-21-and-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-21-and-22/Cargo.toml b/listings/ch07-managing-growing-projects/listing-07-21-and-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-21-and-22/src/front_of_house.rs b/listings/ch07-managing-growing-projects/listing-07-21-and-22/src/front_of_house.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/listing-07-21-and-22/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-21-and-22/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/Cargo.lock b/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/Cargo.toml b/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/src/main.rs b/listings/ch07-managing-growing-projects/no-listing-01-use-std-unnested/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/Cargo.lock b/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/Cargo.toml b/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/front_of_house.rs b/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/front_of_house.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/front_of_house/hosting.rs b/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/front_of_house/hosting.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/lib.rs b/listings/ch07-managing-growing-projects/no-listing-02-extracting-hosting/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/Cargo.lock b/listings/ch07-managing-growing-projects/quick-reference-example/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/Cargo.toml b/listings/ch07-managing-growing-projects/quick-reference-example/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/output.txt b/listings/ch07-managing-growing-projects/quick-reference-example/output.txt old mode 100755 new mode 100644 index e36a45e..04ac6f6 --- a/listings/ch07-managing-growing-projects/quick-reference-example/output.txt +++ b/listings/ch07-managing-growing-projects/quick-reference-example/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling backyard v0.1.0 (file:///projects/backyard) - Finished dev [unoptimized + debuginfo] target(s) in 0.36s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s Running `target/debug/backyard` I'm growing Asparagus! diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/src/garden.rs b/listings/ch07-managing-growing-projects/quick-reference-example/src/garden.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/src/garden/vegetables.rs b/listings/ch07-managing-growing-projects/quick-reference-example/src/garden/vegetables.rs old mode 100755 new mode 100644 diff --git a/listings/ch07-managing-growing-projects/quick-reference-example/src/main.rs b/listings/ch07-managing-growing-projects/quick-reference-example/src/main.rs old mode 100755 new mode 100644 index 7a024a9..0d9a0ca --- a/listings/ch07-managing-growing-projects/quick-reference-example/src/main.rs +++ b/listings/ch07-managing-growing-projects/quick-reference-example/src/main.rs @@ -4,5 +4,5 @@ pub mod garden; fn main() { let plant = Asparagus {}; - println!("I'm growing {:?}!", plant); + println!("I'm growing {plant:?}!"); } diff --git a/listings/ch08-common-collections/listing-08-01/Cargo.lock b/listings/ch08-common-collections/listing-08-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-01/Cargo.toml b/listings/ch08-common-collections/listing-08-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-01/src/main.rs b/listings/ch08-common-collections/listing-08-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-02/Cargo.lock b/listings/ch08-common-collections/listing-08-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-02/Cargo.toml b/listings/ch08-common-collections/listing-08-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-02/src/main.rs b/listings/ch08-common-collections/listing-08-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-03/Cargo.lock b/listings/ch08-common-collections/listing-08-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-03/Cargo.toml b/listings/ch08-common-collections/listing-08-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-03/src/main.rs b/listings/ch08-common-collections/listing-08-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-04/Cargo.lock b/listings/ch08-common-collections/listing-08-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-04/Cargo.toml b/listings/ch08-common-collections/listing-08-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-04/src/main.rs b/listings/ch08-common-collections/listing-08-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-05/Cargo.lock b/listings/ch08-common-collections/listing-08-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-05/Cargo.toml b/listings/ch08-common-collections/listing-08-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-05/src/main.rs b/listings/ch08-common-collections/listing-08-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-06/Cargo.lock b/listings/ch08-common-collections/listing-08-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-06/Cargo.toml b/listings/ch08-common-collections/listing-08-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-06/output.txt b/listings/ch08-common-collections/listing-08-06/output.txt old mode 100755 new mode 100644 index 3104205..f98ab1c --- a/listings/ch08-common-collections/listing-08-06/output.txt +++ b/listings/ch08-common-collections/listing-08-06/output.txt @@ -10,7 +10,7 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta | ^^^^^^^^^ mutable borrow occurs here 7 | 8 | println!("The first element is: {first}"); - | ----- immutable borrow later used here + | ------- immutable borrow later used here For more information about this error, try `rustc --explain E0502`. -error: could not compile `collections` due to previous error +error: could not compile `collections` (bin "collections") due to 1 previous error diff --git a/listings/ch08-common-collections/listing-08-06/src/main.rs b/listings/ch08-common-collections/listing-08-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-07/Cargo.lock b/listings/ch08-common-collections/listing-08-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-07/Cargo.toml b/listings/ch08-common-collections/listing-08-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-07/output.txt b/listings/ch08-common-collections/listing-08-07/output.txt deleted file mode 100755 index ab512a9..0000000 --- a/listings/ch08-common-collections/listing-08-07/output.txt +++ /dev/null @@ -1,16 +0,0 @@ -$ cargo run - Compiling collections v0.1.0 (file:///projects/collections) -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> src/main.rs:6:5 - | -4 | let first = &v[0]; - | - immutable borrow occurs here -5 | -6 | v.push(6); - | ^^^^^^^^^ mutable borrow occurs here -7 | -8 | println!("The first element is: {}", first); - | ----- immutable borrow later used here - -For more information about this error, try `rustc --explain E0502`. -error: could not compile `collections` due to previous error diff --git a/listings/ch08-common-collections/listing-08-07/src/main.rs b/listings/ch08-common-collections/listing-08-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-08/Cargo.lock b/listings/ch08-common-collections/listing-08-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-08/Cargo.toml b/listings/ch08-common-collections/listing-08-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-08/src/main.rs b/listings/ch08-common-collections/listing-08-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-09/Cargo.lock b/listings/ch08-common-collections/listing-08-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-09/Cargo.toml b/listings/ch08-common-collections/listing-08-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-09/src/main.rs b/listings/ch08-common-collections/listing-08-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-10/Cargo.lock b/listings/ch08-common-collections/listing-08-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-10/Cargo.toml b/listings/ch08-common-collections/listing-08-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-10/src/main.rs b/listings/ch08-common-collections/listing-08-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-11/Cargo.lock b/listings/ch08-common-collections/listing-08-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-11/Cargo.toml b/listings/ch08-common-collections/listing-08-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-11/src/main.rs b/listings/ch08-common-collections/listing-08-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-12/Cargo.lock b/listings/ch08-common-collections/listing-08-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-12/Cargo.toml b/listings/ch08-common-collections/listing-08-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-12/src/main.rs b/listings/ch08-common-collections/listing-08-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-13/Cargo.lock b/listings/ch08-common-collections/listing-08-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-13/Cargo.toml b/listings/ch08-common-collections/listing-08-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-13/src/main.rs b/listings/ch08-common-collections/listing-08-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-14/Cargo.lock b/listings/ch08-common-collections/listing-08-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-14/Cargo.toml b/listings/ch08-common-collections/listing-08-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-14/src/main.rs b/listings/ch08-common-collections/listing-08-14/src/main.rs old mode 100755 new mode 100644 index f701fd5..bf737ab --- a/listings/ch08-common-collections/listing-08-14/src/main.rs +++ b/listings/ch08-common-collections/listing-08-14/src/main.rs @@ -3,7 +3,7 @@ fn main() { let hello = String::from("السلام عليكم"); let hello = String::from("Dobrý den"); let hello = String::from("Hello"); - let hello = String::from("שָׁלוֹם"); + let hello = String::from("שלום"); let hello = String::from("नमस्ते"); let hello = String::from("こんにちは"); let hello = String::from("안녕하세요"); diff --git a/listings/ch08-common-collections/listing-08-15/Cargo.lock b/listings/ch08-common-collections/listing-08-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-15/Cargo.toml b/listings/ch08-common-collections/listing-08-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-15/src/main.rs b/listings/ch08-common-collections/listing-08-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-16/Cargo.lock b/listings/ch08-common-collections/listing-08-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-16/Cargo.toml b/listings/ch08-common-collections/listing-08-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-16/src/main.rs b/listings/ch08-common-collections/listing-08-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-17/Cargo.lock b/listings/ch08-common-collections/listing-08-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-17/Cargo.toml b/listings/ch08-common-collections/listing-08-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-17/src/main.rs b/listings/ch08-common-collections/listing-08-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-18/Cargo.lock b/listings/ch08-common-collections/listing-08-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-18/Cargo.toml b/listings/ch08-common-collections/listing-08-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-18/src/main.rs b/listings/ch08-common-collections/listing-08-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-19/Cargo.lock b/listings/ch08-common-collections/listing-08-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-19/Cargo.toml b/listings/ch08-common-collections/listing-08-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-19/output.txt b/listings/ch08-common-collections/listing-08-19/output.txt old mode 100755 new mode 100644 index 9557777..75d9a56 --- a/listings/ch08-common-collections/listing-08-19/output.txt +++ b/listings/ch08-common-collections/listing-08-19/output.txt @@ -1,20 +1,17 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) -error[E0277]: the type `String` cannot be indexed by `{integer}` - --> src/main.rs:3:13 +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> src/main.rs:3:16 | 3 | let h = s1[0]; - | ^^^^^ `String` cannot be indexed by `{integer}` + | ^ string indices are ranges of `usize` | - = help: the trait `Index<{integer}>` is not implemented for `String` - = help: the following other types implement trait `Index`: - >> - > - >> - >> - >> - >> - > + = help: the trait `SliceIndex` is not implemented for `{integer}`, which is required by `String: Index<_>` + = note: you can use `.chars().nth()` or `.bytes().nth()` + for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[_]>` is implemented for `usize` + = help: for that trait implementation, expected `[_]`, found `str` + = note: required for `String` to implement `Index<{integer}>` For more information about this error, try `rustc --explain E0277`. -error: could not compile `collections` due to previous error +error: could not compile `collections` (bin "collections") due to 1 previous error diff --git a/listings/ch08-common-collections/listing-08-19/src/main.rs b/listings/ch08-common-collections/listing-08-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-20/Cargo.lock b/listings/ch08-common-collections/listing-08-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-20/Cargo.toml b/listings/ch08-common-collections/listing-08-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-20/src/main.rs b/listings/ch08-common-collections/listing-08-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-21/Cargo.lock b/listings/ch08-common-collections/listing-08-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-21/Cargo.toml b/listings/ch08-common-collections/listing-08-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-21/src/main.rs b/listings/ch08-common-collections/listing-08-21/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-22/Cargo.lock b/listings/ch08-common-collections/listing-08-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-22/Cargo.toml b/listings/ch08-common-collections/listing-08-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-22/src/main.rs b/listings/ch08-common-collections/listing-08-22/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-23/Cargo.lock b/listings/ch08-common-collections/listing-08-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-23/Cargo.toml b/listings/ch08-common-collections/listing-08-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-23/src/main.rs b/listings/ch08-common-collections/listing-08-23/src/main.rs old mode 100755 new mode 100644 index e8684cf..29025b4 --- a/listings/ch08-common-collections/listing-08-23/src/main.rs +++ b/listings/ch08-common-collections/listing-08-23/src/main.rs @@ -7,6 +7,6 @@ fn main() { scores.insert(String::from("Blue"), 10); scores.insert(String::from("Blue"), 25); - println!("{:?}", scores); + println!("{scores:?}"); // ANCHOR_END: here } diff --git a/listings/ch08-common-collections/listing-08-24/Cargo.lock b/listings/ch08-common-collections/listing-08-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-24/Cargo.toml b/listings/ch08-common-collections/listing-08-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-24/src/main.rs b/listings/ch08-common-collections/listing-08-24/src/main.rs old mode 100755 new mode 100644 index 3ad97b5..0138956 --- a/listings/ch08-common-collections/listing-08-24/src/main.rs +++ b/listings/ch08-common-collections/listing-08-24/src/main.rs @@ -8,6 +8,6 @@ fn main() { scores.entry(String::from("Yellow")).or_insert(50); scores.entry(String::from("Blue")).or_insert(50); - println!("{:?}", scores); + println!("{scores:?}"); // ANCHOR_END: here } diff --git a/listings/ch08-common-collections/listing-08-25/Cargo.lock b/listings/ch08-common-collections/listing-08-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-25/Cargo.toml b/listings/ch08-common-collections/listing-08-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/listing-08-25/src/main.rs b/listings/ch08-common-collections/listing-08-25/src/main.rs old mode 100755 new mode 100644 index f3f6aa1..84dd1cd --- a/listings/ch08-common-collections/listing-08-25/src/main.rs +++ b/listings/ch08-common-collections/listing-08-25/src/main.rs @@ -11,6 +11,6 @@ fn main() { *count += 1; } - println!("{:?}", map); + println!("{map:?}"); // ANCHOR_END: here } diff --git a/listings/ch08-common-collections/listing-08-26/Cargo.lock b/listings/ch08-common-collections/listing-08-26/Cargo.lock deleted file mode 100755 index d3daeff..0000000 --- a/listings/ch08-common-collections/listing-08-26/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "collections" -version = "0.1.0" - diff --git a/listings/ch08-common-collections/listing-08-26/Cargo.toml b/listings/ch08-common-collections/listing-08-26/Cargo.toml deleted file mode 100755 index fe49598..0000000 --- a/listings/ch08-common-collections/listing-08-26/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "collections" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch08-common-collections/listing-08-26/src/main.rs b/listings/ch08-common-collections/listing-08-26/src/main.rs deleted file mode 100755 index f3f6aa1..0000000 --- a/listings/ch08-common-collections/listing-08-26/src/main.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn main() { - // ANCHOR: here - use std::collections::HashMap; - - let text = "hello world wonderful world"; - - let mut map = HashMap::new(); - - for word in text.split_whitespace() { - let count = map.entry(word).or_insert(0); - *count += 1; - } - - println!("{:?}", map); - // ANCHOR_END: here -} diff --git a/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/Cargo.lock b/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/Cargo.toml b/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/src/main.rs b/listings/ch08-common-collections/no-listing-01-concat-multiple-strings/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-02-format/Cargo.lock b/listings/ch08-common-collections/no-listing-02-format/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-02-format/Cargo.toml b/listings/ch08-common-collections/no-listing-02-format/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-02-format/src/main.rs b/listings/ch08-common-collections/no-listing-02-format/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/Cargo.lock b/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/Cargo.toml b/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs b/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/Cargo.lock b/listings/ch08-common-collections/output-only-01-not-char-boundary/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/Cargo.toml b/listings/ch08-common-collections/output-only-01-not-char-boundary/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt old mode 100755 new mode 100644 index 35db879..de65b05 --- a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt +++ b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) - Finished dev [unoptimized + debuginfo] target(s) in 0.43s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/collections` -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/main.rs:4:14 +thread 'main' panicked at src/main.rs:4:19: +byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/src/main.rs b/listings/ch08-common-collections/output-only-01-not-char-boundary/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-01/Cargo.lock b/listings/ch09-error-handling/listing-09-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-01/Cargo.toml b/listings/ch09-error-handling/listing-09-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-01/output.txt b/listings/ch09-error-handling/listing-09-01/output.txt old mode 100755 new mode 100644 index 89aebb9..5f4def0 --- a/listings/ch09-error-handling/listing-09-01/output.txt +++ b/listings/ch09-error-handling/listing-09-01/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling panic v0.1.0 (file:///projects/panic) - Finished dev [unoptimized + debuginfo] target(s) in 0.27s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', src/main.rs:4:5 +thread 'main' panicked at src/main.rs:4:6: +index out of bounds: the len is 3 but the index is 99 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-01/src/main.rs b/listings/ch09-error-handling/listing-09-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-03/Cargo.lock b/listings/ch09-error-handling/listing-09-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-03/Cargo.toml b/listings/ch09-error-handling/listing-09-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-03/src/main.rs b/listings/ch09-error-handling/listing-09-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-04/Cargo.lock b/listings/ch09-error-handling/listing-09-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-04/Cargo.toml b/listings/ch09-error-handling/listing-09-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-04/output.txt b/listings/ch09-error-handling/listing-09-04/output.txt old mode 100755 new mode 100644 index f776a59..b36bdc0 --- a/listings/ch09-error-handling/listing-09-04/output.txt +++ b/listings/ch09-error-handling/listing-09-04/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling error-handling v0.1.0 (file:///projects/error-handling) - Finished dev [unoptimized + debuginfo] target(s) in 0.73s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.73s Running `target/debug/error-handling` -thread 'main' panicked at 'Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:8:23 +thread 'main' panicked at src/main.rs:8:23: +Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-04/src/main.rs b/listings/ch09-error-handling/listing-09-04/src/main.rs old mode 100755 new mode 100644 index 69da109..832f57f --- a/listings/ch09-error-handling/listing-09-04/src/main.rs +++ b/listings/ch09-error-handling/listing-09-04/src/main.rs @@ -5,6 +5,6 @@ fn main() { let greeting_file = match greeting_file_result { Ok(file) => file, - Err(error) => panic!("Problem opening the file: {:?}", error), + Err(error) => panic!("Problem opening the file: {error:?}"), }; } diff --git a/listings/ch09-error-handling/listing-09-05/Cargo.lock b/listings/ch09-error-handling/listing-09-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-05/Cargo.toml b/listings/ch09-error-handling/listing-09-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-05/src/main.rs b/listings/ch09-error-handling/listing-09-05/src/main.rs old mode 100755 new mode 100644 index 83ea010..e0bc55c --- a/listings/ch09-error-handling/listing-09-05/src/main.rs +++ b/listings/ch09-error-handling/listing-09-05/src/main.rs @@ -9,10 +9,10 @@ fn main() { Err(error) => match error.kind() { ErrorKind::NotFound => match File::create("hello.txt") { Ok(fc) => fc, - Err(e) => panic!("Problem creating the file: {:?}", e), + Err(e) => panic!("Problem creating the file: {e:?}"), }, other_error => { - panic!("Problem opening the file: {:?}", other_error); + panic!("Problem opening the file: {other_error:?}"); } }, }; diff --git a/listings/ch09-error-handling/listing-09-06/Cargo.lock b/listings/ch09-error-handling/listing-09-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-06/Cargo.toml b/listings/ch09-error-handling/listing-09-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-06/src/main.rs b/listings/ch09-error-handling/listing-09-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-07/Cargo.lock b/listings/ch09-error-handling/listing-09-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-07/Cargo.toml b/listings/ch09-error-handling/listing-09-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-07/src/main.rs b/listings/ch09-error-handling/listing-09-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-08/Cargo.lock b/listings/ch09-error-handling/listing-09-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-08/Cargo.toml b/listings/ch09-error-handling/listing-09-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-08/src/main.rs b/listings/ch09-error-handling/listing-09-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-09/Cargo.lock b/listings/ch09-error-handling/listing-09-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-09/Cargo.toml b/listings/ch09-error-handling/listing-09-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-09/src/main.rs b/listings/ch09-error-handling/listing-09-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-10/Cargo.lock b/listings/ch09-error-handling/listing-09-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-10/Cargo.toml b/listings/ch09-error-handling/listing-09-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-10/output.txt b/listings/ch09-error-handling/listing-09-10/output.txt old mode 100755 new mode 100644 index 75b9cf2..dbc9bb1 --- a/listings/ch09-error-handling/listing-09-10/output.txt +++ b/listings/ch09-error-handling/listing-09-10/output.txt @@ -11,4 +11,4 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu = help: the trait `FromResidual>` is not implemented for `()` For more information about this error, try `rustc --explain E0277`. -error: could not compile `error-handling` due to previous error +error: could not compile `error-handling` (bin "error-handling") due to 1 previous error diff --git a/listings/ch09-error-handling/listing-09-10/src/main.rs b/listings/ch09-error-handling/listing-09-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-11/Cargo.lock b/listings/ch09-error-handling/listing-09-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-11/Cargo.toml b/listings/ch09-error-handling/listing-09-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-11/src/main.rs b/listings/ch09-error-handling/listing-09-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-12/Cargo.lock b/listings/ch09-error-handling/listing-09-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-12/Cargo.toml b/listings/ch09-error-handling/listing-09-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-12/src/main.rs b/listings/ch09-error-handling/listing-09-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-13/Cargo.lock b/listings/ch09-error-handling/listing-09-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-13/Cargo.toml b/listings/ch09-error-handling/listing-09-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/listing-09-13/src/lib.rs b/listings/ch09-error-handling/listing-09-13/src/lib.rs new file mode 100644 index 0000000..d093831 --- /dev/null +++ b/listings/ch09-error-handling/listing-09-13/src/lib.rs @@ -0,0 +1,17 @@ +pub struct Guess { + value: i32, +} + +impl Guess { + pub fn new(value: i32) -> Guess { + if value < 1 || value > 100 { + panic!("Guess value must be between 1 and 100, got {value}."); + } + + Guess { value } + } + + pub fn value(&self) -> i32 { + self.value + } +} diff --git a/listings/ch09-error-handling/listing-09-13/src/main.rs b/listings/ch09-error-handling/listing-09-13/src/main.rs old mode 100755 new mode 100644 index 9e07c1e..cda3893 --- a/listings/ch09-error-handling/listing-09-13/src/main.rs +++ b/listings/ch09-error-handling/listing-09-13/src/main.rs @@ -1,27 +1,8 @@ +use guessing_game::Guess; use rand::Rng; use std::cmp::Ordering; use std::io; -// ANCHOR: here -pub struct Guess { - value: i32, -} - -impl Guess { - pub fn new(value: i32) -> Guess { - if value < 1 || value > 100 { - panic!("Guess value must be between 1 and 100, got {}.", value); - } - - Guess { value } - } - - pub fn value(&self) -> i32 { - self.value - } -} -// ANCHOR_END: here - fn main() { println!("Guess the number!"); diff --git a/listings/ch09-error-handling/no-listing-01-panic/Cargo.lock b/listings/ch09-error-handling/no-listing-01-panic/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-01-panic/Cargo.toml b/listings/ch09-error-handling/no-listing-01-panic/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-01-panic/output.txt b/listings/ch09-error-handling/no-listing-01-panic/output.txt old mode 100755 new mode 100644 index b25ed85..ced4ee7 --- a/listings/ch09-error-handling/no-listing-01-panic/output.txt +++ b/listings/ch09-error-handling/no-listing-01-panic/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling panic v0.1.0 (file:///projects/panic) - Finished dev [unoptimized + debuginfo] target(s) in 0.25s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.25s Running `target/debug/panic` -thread 'main' panicked at 'crash and burn', src/main.rs:2:5 +thread 'main' panicked at src/main.rs:2:5: +crash and burn note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/no-listing-01-panic/src/main.rs b/listings/ch09-error-handling/no-listing-01-panic/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.lock b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.lock deleted file mode 100755 index 1fa96b7..0000000 --- a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "error-handling" -version = "0.1.0" - diff --git a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.toml b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.toml deleted file mode 100755 index c496db7..0000000 --- a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "error-handling" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt deleted file mode 100755 index aa95afa..0000000 --- a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt +++ /dev/null @@ -1,15 +0,0 @@ -$ cargo run - Compiling error-handling v0.1.0 (file:///projects/error-handling) -error[E0308]: mismatched types - --> src/main.rs:4:18 - | -4 | let f: u32 = File::open("hello.txt"); - | --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found enum `Result` - | | - | expected due to this - | - = note: expected type `u32` - found enum `Result` - -For more information about this error, try `rustc --explain E0308`. -error: could not compile `error-handling` due to previous error diff --git a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/src/main.rs b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/src/main.rs deleted file mode 100755 index a637f5f..0000000 --- a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/src/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -use std::fs::File; - -fn main() { - // ANCHOR: here - let f: u32 = File::open("hello.txt"); - // ANCHOR_END: here -} diff --git a/listings/ch09-error-handling/no-listing-04-unwrap/Cargo.lock b/listings/ch09-error-handling/no-listing-04-unwrap/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-04-unwrap/Cargo.toml b/listings/ch09-error-handling/no-listing-04-unwrap/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-04-unwrap/src/main.rs b/listings/ch09-error-handling/no-listing-04-unwrap/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-05-expect/Cargo.lock b/listings/ch09-error-handling/no-listing-05-expect/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-05-expect/Cargo.toml b/listings/ch09-error-handling/no-listing-05-expect/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-05-expect/src/main.rs b/listings/ch09-error-handling/no-listing-05-expect/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/Cargo.lock b/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/Cargo.toml b/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/src/main.rs b/listings/ch09-error-handling/no-listing-08-unwrap-that-cant-fail/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-09-guess-out-of-range/Cargo.lock b/listings/ch09-error-handling/no-listing-09-guess-out-of-range/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-09-guess-out-of-range/Cargo.toml b/listings/ch09-error-handling/no-listing-09-guess-out-of-range/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch09-error-handling/no-listing-09-guess-out-of-range/src/main.rs b/listings/ch09-error-handling/no-listing-09-guess-out-of-range/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/src/main.rs old mode 100755 new mode 100644 index a4dba7e..c9e9bbb --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-01/src/main.rs @@ -10,7 +10,7 @@ fn main() { } } - println!("The largest number is {}", largest); + println!("The largest number is {largest}"); // ANCHOR_END: here assert_eq!(*largest, 100); // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/src/main.rs old mode 100755 new mode 100644 index 8c523a8..fd43154 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/src/main.rs @@ -9,7 +9,7 @@ fn main() { } } - println!("The largest number is {}", largest); + println!("The largest number is {largest}"); let number_list = vec![102, 34, 6000, 89, 54, 2, 43, 8]; @@ -21,5 +21,5 @@ fn main() { } } - println!("The largest number is {}", largest); + println!("The largest number is {largest}"); } diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs old mode 100755 new mode 100644 index 8992229..1878f5a --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs @@ -15,7 +15,7 @@ fn main() { let number_list = vec![34, 50, 25, 100, 65]; let result = largest(&number_list); - println!("The largest number is {}", result); + println!("The largest number is {result}"); // ANCHOR_END: here assert_eq!(*result, 100); // ANCHOR: here @@ -23,7 +23,7 @@ fn main() { let number_list = vec![102, 34, 6000, 89, 54, 2, 43, 8]; let result = largest(&number_list); - println!("The largest number is {}", result); + println!("The largest number is {result}"); // ANCHOR_END: here assert_eq!(*result, 6000); // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/src/main.rs old mode 100755 new mode 100644 index a47e3f2..ac3b1f7 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/src/main.rs @@ -27,7 +27,7 @@ fn main() { let number_list = vec![34, 50, 25, 100, 65]; let result = largest_i32(&number_list); - println!("The largest number is {}", result); + println!("The largest number is {result}"); // ANCHOR_END: here assert_eq!(*result, 100); // ANCHOR: here @@ -35,7 +35,7 @@ fn main() { let char_list = vec!['y', 'm', 'a', 'q']; let result = largest_char(&char_list); - println!("The largest char is {}", result); + println!("The largest char is {result}"); // ANCHOR_END: here assert_eq!(*result, 'y'); // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt old mode 100755 new mode 100644 index 1a705ed..05b96ca --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt @@ -14,4 +14,4 @@ help: consider restricting type parameter `T` | ++++++++++++++++++++++ For more information about this error, try `rustc --explain E0369`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 1 previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/src/main.rs old mode 100755 new mode 100644 index df33743..094eb41 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/src/main.rs @@ -14,10 +14,10 @@ fn main() { let number_list = vec![34, 50, 25, 100, 65]; let result = largest(&number_list); - println!("The largest number is {}", result); + println!("The largest number is {result}"); let char_list = vec!['y', 'm', 'a', 'q']; let result = largest(&char_list); - println!("The largest char is {}", result); + println!("The largest char is {result}"); } diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt old mode 100755 new mode 100644 index 2482c38..5f6c3f4 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt @@ -7,4 +7,4 @@ error[E0308]: mismatched types | ^^^ expected integer, found floating-point number For more information about this error, try `rustc --explain E0308`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 1 previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/src/main.rs deleted file mode 100755 index 7aa6a3b..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-15/src/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -fn largest(list: &[T]) -> T { - let mut largest = list[0]; - - for &item in list { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest(&number_list); - println!("The largest number is {}", result); - - let char_list = vec!['y', 'm', 'a', 'q']; - - let result = largest(&char_list); - println!("The largest char is {}", result); -} diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/output.txt old mode 100755 new mode 100644 index ad73272..5c44142 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/output.txt @@ -3,13 +3,15 @@ $ cargo run error[E0597]: `x` does not live long enough --> src/main.rs:6:13 | +5 | let x = 5; + | - binding `x` declared here 6 | r = &x; | ^^ borrowed value does not live long enough 7 | } | - `x` dropped here while still borrowed 8 | -9 | println!("r: {}", r); - | - borrow later used here +9 | println!("r: {r}"); + | --- borrow later used here For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 1 previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/lib.rs deleted file mode 100755 index 669cc5f..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/lib.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::fmt::Display; - -struct Pair { - x: T, - y: T, -} - -impl Pair { - fn new(x: T, y: T) -> Self { - Self { x, y } - } -} - -impl Pair { - fn cmp_display(&self) { - if self.x >= self.y { - println!("The largest member is x = {}", self.x); - } else { - println!("The largest member is y = {}", self.y); - } - } -} diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/main.rs old mode 100755 new mode 100644 index d71134e..773340e --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/main.rs @@ -6,5 +6,5 @@ fn main() { r = &x; } - println!("r: {}", r); + println!("r: {r}"); } diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt deleted file mode 100755 index 8b239e4..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt +++ /dev/null @@ -1,15 +0,0 @@ -$ cargo run - Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0597]: `x` does not live long enough - --> src/main.rs:7:17 - | -7 | r = &x; - | ^^ borrowed value does not live long enough -8 | } - | - `x` dropped here while still borrowed -9 | -10 | println!("r: {}", r); - | - borrow later used here - -For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10` due to previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/rustfmt-ignore b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/src/main.rs old mode 100755 new mode 100644 index e8ca923..6679bcf --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/src/main.rs @@ -6,5 +6,5 @@ fn main() { r = &x; // | | } // -+ | // | - println!("r: {}", r); // | + println!("r: {r}"); // | } // ---------+ diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/rustfmt-ignore b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/src/main.rs old mode 100755 new mode 100644 index 09ae391..634ff93 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/src/main.rs @@ -3,6 +3,6 @@ fn main() { // | let r = &x; // --+-- 'a | // | | - println!("r: {}", r); // | | + println!("r: {r}"); // | | // --+ | } // ----------+ diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/rustfmt-ignore b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/rustfmt-ignore deleted file mode 100755 index 9a53c71..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/rustfmt-ignore +++ /dev/null @@ -1,3 +0,0 @@ -We have some weird comments pointing out borrowing scopes that we don't want to change; -unfortunately I haven't found a way to skip them with rustfmt that works so for now we're going to -manually skip those listings. See: https://github.com/rust-lang/rustfmt/issues/4028 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/src/main.rs old mode 100755 new mode 100644 index 0f076a7..8b64cd0 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/src/main.rs @@ -3,5 +3,5 @@ fn main() { let string2 = "xyz"; let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/output.txt old mode 100755 new mode 100644 index 534a984..1af8bd5 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/output.txt @@ -12,5 +12,23 @@ help: consider introducing a named lifetime parameter 9 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { | ++++ ++ ++ ++ +error: lifetime may not live long enough + --> src/main.rs:11:9 + | +9 | fn longest(x: &str, y: &str) -> &str { + | - let's call the lifetime of this reference `'1` +10 | if x.len() > y.len() { +11 | x + | ^ returning this value requires that `'1` must outlive `'static` + +error: lifetime may not live long enough + --> src/main.rs:13:9 + | +9 | fn longest(x: &str, y: &str) -> &str { + | - let's call the lifetime of this reference `'2` +... +13 | y + | ^ returning this value requires that `'2` must outlive `'static` + For more information about this error, try `rustc --explain E0106`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 3 previous errors diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs old mode 100755 new mode 100644 index 6af8c9f..bf41acd --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs @@ -3,7 +3,7 @@ fn main() { let string2 = "xyz"; let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt deleted file mode 100755 index 534a984..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt +++ /dev/null @@ -1,16 +0,0 @@ -$ cargo run - Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0106]: missing lifetime specifier - --> src/main.rs:9:33 - | -9 | fn longest(x: &str, y: &str) -> &str { - | ---- ---- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y` -help: consider introducing a named lifetime parameter - | -9 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { - | ++++ ++ ++ ++ - -For more information about this error, try `rustc --explain E0106`. -error: could not compile `chapter10` due to previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/src/main.rs old mode 100755 new mode 100644 index 09c3a0d..7668de1 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/src/main.rs @@ -3,7 +3,7 @@ fn main() { let string2 = "xyz"; let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/src/main.rs old mode 100755 new mode 100644 index 836ec72..fc9ff29 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/src/main.rs @@ -5,7 +5,7 @@ fn main() { { let string2 = String::from("xyz"); let result = longest(string1.as_str(), string2.as_str()); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } } // ANCHOR_END: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/output.txt old mode 100755 new mode 100644 index 7f31ce0..cb209ab --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/output.txt @@ -3,12 +3,14 @@ $ cargo run error[E0597]: `string2` does not live long enough --> src/main.rs:6:44 | +5 | let string2 = String::from("xyz"); + | ------- binding `string2` declared here 6 | result = longest(string1.as_str(), string2.as_str()); - | ^^^^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^ borrowed value does not live long enough 7 | } | - `string2` dropped here while still borrowed -8 | println!("The longest string is {}", result); - | ------ borrow later used here +8 | println!("The longest string is {result}"); + | -------- borrow later used here For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 1 previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/src/main.rs old mode 100755 new mode 100644 index 2a6fa58..f2e6338 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/src/main.rs @@ -6,7 +6,7 @@ fn main() { let string2 = String::from("xyz"); result = longest(string1.as_str(), string2.as_str()); } - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR_END: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt deleted file mode 100755 index 7f31ce0..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt +++ /dev/null @@ -1,14 +0,0 @@ -$ cargo run - Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0597]: `string2` does not live long enough - --> src/main.rs:6:44 - | -6 | result = longest(string1.as_str(), string2.as_str()); - | ^^^^^^^^^^^^^^^^ borrowed value does not live long enough -7 | } - | - `string2` dropped here while still borrowed -8 | println!("The longest string is {}", result); - | ------ borrow later used here - -For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10` due to previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs old mode 100755 new mode 100644 index 2937b19..ca3cf86 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs @@ -4,7 +4,7 @@ struct ImportantExcerpt<'a> { fn main() { let novel = String::from("Call me Ishmael. Some years ago..."); - let first_sentence = novel.split('.').next().expect("Could not find a '.'"); + let first_sentence = novel.split('.').next().unwrap(); let i = ImportantExcerpt { part: first_sentence, }; diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.lock deleted file mode 100755 index 2aa4918..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "ownership" -version = "0.1.0" - diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.toml deleted file mode 100755 index e884752..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "ownership" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/src/main.rs deleted file mode 100755 index 431a261..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-26/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -// ANCHOR: here -fn first_word(s: &str) -> &str { - let bytes = s.as_bytes(); - - for (i, &item) in bytes.iter().enumerate() { - if item == b' ' { - return &s[0..i]; - } - } - - &s[..] -} -// ANCHOR_END: here - -fn main() { - let my_string = String::from("hello world"); - - // first_word works on slices of `String`s - let word = first_word(&my_string[..]); - - let my_string_literal = "hello world"; - - // first_word works on slices of string literals - let word = first_word(&my_string_literal[..]); - - // Because string literals *are* string slices already, - // this works too, without the slice syntax! - let word = first_word(my_string_literal); -} diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-01-calling-trait-method/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-02-calling-default-impl/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-05-returning-impl-trait/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-06-impl-trait-returns-one-type/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.lock deleted file mode 100755 index e8007a1..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "chapter10" -version = "0.1.0" - diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.toml deleted file mode 100755 index 489f809..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "chapter10" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt deleted file mode 100755 index eca02c2..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt +++ /dev/null @@ -1,25 +0,0 @@ -$ cargo run - Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> src/main.rs:2:23 - | -2 | let mut largest = list[0]; - | ^^^^^^^ - | | - | cannot move out of here - | move occurs because `list[_]` has type `T`, which does not implement the `Copy` trait - | help: consider borrowing here: `&list[0]` - -error[E0507]: cannot move out of a shared reference - --> src/main.rs:4:18 - | -4 | for &item in list { - | ----- ^^^^ - | || - | |data moved here - | |move occurs because `item` has type `T`, which does not implement the `Copy` trait - | help: consider removing the `&`: `item` - -Some errors have detailed explanations: E0507, E0508. -For more information about an error, try `rustc --explain E0507`. -error: could not compile `chapter10` due to 2 previous errors diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/src/main.rs deleted file mode 100755 index 525ce81..0000000 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/src/main.rs +++ /dev/null @@ -1,25 +0,0 @@ -// ANCHOR: here -fn largest(list: &[T]) -> T { - // ANCHOR_END: here - let mut largest = list[0]; - - for &item in list { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest(&number_list); - println!("The largest number is {}", result); - - let char_list = vec!['y', 'm', 'a', 'q']; - - let result = largest(&char_list); - println!("The largest char is {}", result); -} diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-where-clause/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-where-clause/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-where-clause/src/lib.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-where-clause/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs old mode 100755 new mode 100644 index d144305..4c35d90 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs @@ -3,7 +3,7 @@ fn main() { let string2 = "efghijklmnopqrstuvwxyz"; let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt old mode 100755 new mode 100644 index 0c628b6..9b9ef23 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt @@ -1,10 +1,13 @@ $ cargo run Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0515]: cannot return reference to local variable `result` +error[E0515]: cannot return value referencing local variable `result` --> src/main.rs:11:5 | 11 | result.as_str() - | ^^^^^^^^^^^^^^^ returns a reference to data owned by the current function + | ------^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `result` is borrowed here For more information about this error, try `rustc --explain E0515`. -error: could not compile `chapter10` due to previous error +error: could not compile `chapter10` (bin "chapter10") due to 1 previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs old mode 100755 new mode 100644 index aca4be0..4d596ec --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs @@ -3,7 +3,7 @@ fn main() { let string2 = "xyz"; let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR: here diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs old mode 100755 new mode 100644 index 32ad530..c04ec38 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs @@ -13,7 +13,7 @@ impl<'a> ImportantExcerpt<'a> { // ANCHOR: 3rd impl<'a> ImportantExcerpt<'a> { fn announce_and_return_part(&self, announcement: &str) -> &str { - println!("Attention please: {}", announcement); + println!("Attention please: {announcement}"); self.part } } @@ -21,7 +21,7 @@ impl<'a> ImportantExcerpt<'a> { fn main() { let novel = String::from("Call me Ishmael. Some years ago..."); - let first_sentence = novel.split('.').next().expect("Could not find a '.'"); + let first_sentence = novel.split('.').next().unwrap(); let i = ImportantExcerpt { part: first_sentence, }; diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/Cargo.lock b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/Cargo.toml b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/src/main.rs old mode 100755 new mode 100644 index cfafa9a..4b0201f --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/src/main.rs +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/src/main.rs @@ -7,7 +7,7 @@ fn main() { string2, "Today is someone's birthday!", ); - println!("The longest string is {}", result); + println!("The longest string is {result}"); } // ANCHOR: here @@ -21,7 +21,7 @@ fn longest_with_an_announcement<'a, T>( where T: Display, { - println!("Announcement! {}", ann); + println!("Announcement! {ann}"); if x.len() > y.len() { x } else { diff --git a/listings/ch11-writing-automated-tests/listing-11-01/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-01/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-01/output.txt b/listings/ch11-writing-automated-tests/listing-11-01/output.txt old mode 100755 new mode 100644 index c3e812e..128309c --- a/listings/ch11-writing-automated-tests/listing-11-01/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-01/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.57s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.57s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs old mode 100755 new mode 100644 index 1b4a90c..7d12d9a --- a/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs @@ -1,8 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn it_works() { - let result = 2 + 2; + let result = add(2, 2); assert_eq!(result, 4); } } diff --git a/listings/ch11-writing-automated-tests/listing-11-03/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-03/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-03/output.txt b/listings/ch11-writing-automated-tests/listing-11-03/output.txt old mode 100755 new mode 100644 index 2fa5cf0..cf2c206 --- a/listings/ch11-writing-automated-tests/listing-11-03/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-03/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.72s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.72s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 2 tests @@ -10,7 +10,8 @@ test tests::exploration ... ok failures: ---- tests::another stdout ---- -thread 'main' panicked at 'Make this test fail', src/lib.rs:10:9 +thread 'tests::another' panicked at src/lib.rs:17:9: +Make this test fail note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs old mode 100755 new mode 100644 index a9ec008..67b6552 --- a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs @@ -1,11 +1,18 @@ // ANCHOR: here +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn exploration() { - assert_eq!(2 + 2, 4); + let result = add(2, 2); + assert_eq!(result, 4); } - + #[test] fn another() { panic!("Make this test fail"); diff --git a/listings/ch11-writing-automated-tests/listing-11-05/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-05/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-06/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-06/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-06/output.txt b/listings/ch11-writing-automated-tests/listing-11-06/output.txt old mode 100755 new mode 100644 index dad02b4..e03add2 --- a/listings/ch11-writing-automated-tests/listing-11-06/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-06/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling rectangle v0.1.0 (file:///projects/rectangle) - Finished test [unoptimized + debuginfo] target(s) in 0.66s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s Running unittests src/lib.rs (target/debug/deps/rectangle-6584c4561e48942e) running 1 test diff --git a/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-07/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-07/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-07/output.txt b/listings/ch11-writing-automated-tests/listing-11-07/output.txt old mode 100755 new mode 100644 index fa02835..908ed57 --- a/listings/ch11-writing-automated-tests/listing-11-07/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-07/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.58s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.58s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-08/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-08/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-08/output.txt b/listings/ch11-writing-automated-tests/listing-11-08/output.txt old mode 100755 new mode 100644 index caca154..a5a7643 --- a/listings/ch11-writing-automated-tests/listing-11-08/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-08/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished test [unoptimized + debuginfo] target(s) in 0.58s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.58s Running unittests src/lib.rs (target/debug/deps/guessing_game-57d70c3acb738f4d) running 1 test diff --git a/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs old mode 100755 new mode 100644 index 9391be5..54e447b --- a/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs @@ -5,7 +5,7 @@ pub struct Guess { impl Guess { pub fn new(value: i32) -> Guess { if value < 1 || value > 100 { - panic!("Guess value must be between 1 and 100, got {}.", value); + panic!("Guess value must be between 1 and 100, got {value}."); } Guess { value } diff --git a/listings/ch11-writing-automated-tests/listing-11-09/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-09/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs old mode 100755 new mode 100644 index cc1c5c3..1bb4641 --- a/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs @@ -9,13 +9,11 @@ impl Guess { pub fn new(value: i32) -> Guess { if value < 1 { panic!( - "Guess value must be greater than or equal to 1, got {}.", - value + "Guess value must be greater than or equal to 1, got {value}." ); } else if value > 100 { panic!( - "Guess value must be less than or equal to 100, got {}.", - value + "Guess value must be less than or equal to 100, got {value}." ); } diff --git a/listings/ch11-writing-automated-tests/listing-11-10/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-10/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-10/output.txt b/listings/ch11-writing-automated-tests/listing-11-10/output.txt old mode 100755 new mode 100644 index 681cfbb..36fae57 --- a/listings/ch11-writing-automated-tests/listing-11-10/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-10/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling silly-function v0.1.0 (file:///projects/silly-function) - Finished test [unoptimized + debuginfo] target(s) in 0.58s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.58s Running unittests src/lib.rs (target/debug/deps/silly_function-160869f38cff9166) running 2 tests @@ -11,9 +11,10 @@ failures: ---- tests::this_test_will_fail stdout ---- I got the value 8 -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `5`, - right: `10`', src/lib.rs:19:9 +thread 'tests::this_test_will_fail' panicked at src/lib.rs:19:9: +assertion `left == right` failed + left: 5 + right: 10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs old mode 100755 new mode 100644 index 6fd76ce..99fc06b --- a/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs @@ -1,5 +1,5 @@ fn prints_and_returns_10(a: i32) -> i32 { - println!("I got the value {}", a); + println!("I got the value {a}"); 10 } diff --git a/listings/ch11-writing-automated-tests/listing-11-11/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-11/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-11/output.txt b/listings/ch11-writing-automated-tests/listing-11-11/output.txt old mode 100755 new mode 100644 index fe19c83..a0fe55d --- a/listings/ch11-writing-automated-tests/listing-11-11/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-11/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.62s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.62s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 3 tests diff --git a/listings/ch11-writing-automated-tests/listing-11-11/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-11/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-12/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-12/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-13/Cargo.lock b/listings/ch11-writing-automated-tests/listing-11-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-13/Cargo.toml b/listings/ch11-writing-automated-tests/listing-11-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-13/output.txt b/listings/ch11-writing-automated-tests/listing-11-13/output.txt old mode 100755 new mode 100644 index 22970e9..84344ad --- a/listings/ch11-writing-automated-tests/listing-11-13/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-13/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 1.31s + Finished `test` profile [unoptimized + debuginfo] target(s) in 1.31s Running unittests src/lib.rs (target/debug/deps/adder-1082c4b063a8fbe6) running 1 test diff --git a/listings/ch11-writing-automated-tests/listing-11-13/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/listing-11-13/tests/integration_test.rs b/listings/ch11-writing-automated-tests/listing-11-13/tests/integration_test.rs old mode 100755 new mode 100644 index e26fa71..3822d6b --- a/listings/ch11-writing-automated-tests/listing-11-13/tests/integration_test.rs +++ b/listings/ch11-writing-automated-tests/listing-11-13/tests/integration_test.rs @@ -1,6 +1,6 @@ -use adder; +use adder::add_two; #[test] fn it_adds_two() { - assert_eq!(4, adder::add_two(2)); + assert_eq!(4, add_two(2)); } diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/output.txt b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/output.txt old mode 100755 new mode 100644 index 8a33308..79d3ae2 --- a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.59s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.59s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs old mode 100755 new mode 100644 index 330bddf..5be58b9 --- a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs @@ -1,7 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn exploration() { - assert_eq!(2 + 2, 4); + let result = add(2, 2); + assert_eq!(result, 4); } } diff --git a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/output.txt b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/output.txt old mode 100755 new mode 100644 index 30e45e5..6304403 --- a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling rectangle v0.1.0 (file:///projects/rectangle) - Finished test [unoptimized + debuginfo] target(s) in 0.66s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s Running unittests src/lib.rs (target/debug/deps/rectangle-6584c4561e48942e) running 2 tests diff --git a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt old mode 100755 new mode 100644 index 7c62822..6d616db --- a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling rectangle v0.1.0 (file:///projects/rectangle) - Finished test [unoptimized + debuginfo] target(s) in 0.66s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s Running unittests src/lib.rs (target/debug/deps/rectangle-6584c4561e48942e) running 2 tests @@ -10,7 +10,8 @@ test tests::smaller_cannot_hold_larger ... ok failures: ---- tests::larger_can_hold_smaller stdout ---- -thread 'main' panicked at 'assertion failed: larger.can_hold(&smaller)', src/lib.rs:28:9 +thread 'tests::larger_can_hold_smaller' panicked at src/lib.rs:28:9: +assertion failed: larger.can_hold(&smaller) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt old mode 100755 new mode 100644 index 28e2414..5e91c58 --- a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.61s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.61s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test @@ -9,9 +9,10 @@ test tests::it_adds_two ... FAILED failures: ---- tests::it_adds_two stdout ---- -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `4`, - right: `5`', src/lib.rs:11:9 +thread 'tests::it_adds_two' panicked at src/lib.rs:11:9: +assertion `left == right` failed + left: 4 + right: 5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-05-greeter/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-05-greeter/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-05-greeter/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-05-greeter/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs old mode 100755 new mode 100644 index 3ba3d88..433cf14 --- a/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs @@ -1,5 +1,5 @@ pub fn greeting(name: &str) -> String { - format!("Hello {}!", name) + format!("Hello {name}!") } #[cfg(test)] diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt old mode 100755 new mode 100644 index 3366e3a..0a7d44d --- a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling greeter v0.1.0 (file:///projects/greeter) - Finished test [unoptimized + debuginfo] target(s) in 0.91s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.91s Running unittests src/lib.rs (target/debug/deps/greeter-170b942eb5bf5e3a) running 1 test @@ -9,7 +9,8 @@ test tests::greeting_contains_name ... FAILED failures: ---- tests::greeting_contains_name stdout ---- -thread 'main' panicked at 'assertion failed: result.contains(\"Carol\")', src/lib.rs:12:9 +thread 'tests::greeting_contains_name' panicked at src/lib.rs:12:9: +assertion failed: result.contains("Carol") note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt old mode 100755 new mode 100644 index cebebda..d2015d5 --- a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling greeter v0.1.0 (file:///projects/greeter) - Finished test [unoptimized + debuginfo] target(s) in 0.93s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.93s Running unittests src/lib.rs (target/debug/deps/greeter-170b942eb5bf5e3a) running 1 test @@ -9,7 +9,8 @@ test tests::greeting_contains_name ... FAILED failures: ---- tests::greeting_contains_name stdout ---- -thread 'main' panicked at 'Greeting did not contain name, value was `Hello!`', src/lib.rs:12:9 +thread 'tests::greeting_contains_name' panicked at src/lib.rs:12:9: +Greeting did not contain name, value was `Hello!` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/output.txt old mode 100755 new mode 100644 index 9318d4c..9b7ec43 --- a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished test [unoptimized + debuginfo] target(s) in 0.62s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.62s Running unittests src/lib.rs (target/debug/deps/guessing_game-57d70c3acb738f4d) running 1 test diff --git a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs old mode 100755 new mode 100644 index 32540ba..0f962fc --- a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs @@ -7,7 +7,7 @@ pub struct Guess { impl Guess { pub fn new(value: i32) -> Guess { if value < 1 { - panic!("Guess value must be between 1 and 100, got {}.", value); + panic!("Guess value must be between 1 and 100, got {value}."); } Guess { value } diff --git a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt old mode 100755 new mode 100644 index c176e88..f30b55a --- a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished test [unoptimized + debuginfo] target(s) in 0.66s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s Running unittests src/lib.rs (target/debug/deps/guessing_game-57d70c3acb738f4d) running 1 test @@ -9,7 +9,8 @@ test tests::greater_than_100 - should panic ... FAILED failures: ---- tests::greater_than_100 stdout ---- -thread 'main' panicked at 'Guess value must be greater than or equal to 1, got 200.', src/lib.rs:13:13 +thread 'tests::greater_than_100' panicked at src/lib.rs:12:13: +Guess value must be greater than or equal to 1, got 200. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: panic did not contain expected string panic message: `"Guess value must be greater than or equal to 1, got 200."`, diff --git a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs old mode 100755 new mode 100644 index 7703dd7..fb5fc0e --- a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/src/lib.rs @@ -7,13 +7,11 @@ impl Guess { // ANCHOR: here if value < 1 { panic!( - "Guess value must be less than or equal to 100, got {}.", - value + "Guess value must be less than or equal to 100, got {value}." ); } else if value > 100 { panic!( - "Guess value must be greater than or equal to 1, got {}.", - value + "Guess value must be greater than or equal to 1, got {value}." ); } // ANCHOR_END: here diff --git a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/output.txt b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/output.txt old mode 100755 new mode 100644 index c559de8..8d700c7 --- a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.60s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.60s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 2 tests diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/output.txt b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/output.txt old mode 100755 new mode 100644 index 324d566..e258394 --- a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.89s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.89s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/tests/common.rs b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/tests/common.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/tests/integration_test.rs b/listings/ch11-writing-automated-tests/no-listing-12-shared-test-code-problem/tests/integration_test.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/Cargo.lock b/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/Cargo.toml b/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/tests/common/mod.rs b/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/tests/common/mod.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/tests/integration_test.rs b/listings/ch11-writing-automated-tests/no-listing-13-fix-shared-test-code-problem/tests/integration_test.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-01-show-output/Cargo.lock b/listings/ch11-writing-automated-tests/output-only-01-show-output/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-01-show-output/Cargo.toml b/listings/ch11-writing-automated-tests/output-only-01-show-output/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt b/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt old mode 100755 new mode 100644 index 4ececf2..58f1ff4 --- a/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt @@ -1,6 +1,6 @@ $ cargo test -- --show-output Compiling silly-function v0.1.0 (file:///projects/silly-function) - Finished test [unoptimized + debuginfo] target(s) in 0.60s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.60s Running unittests src/lib.rs (target/debug/deps/silly_function-160869f38cff9166) running 2 tests @@ -20,9 +20,10 @@ failures: ---- tests::this_test_will_fail stdout ---- I got the value 8 -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `5`, - right: `10`', src/lib.rs:19:9 +thread 'tests::this_test_will_fail' panicked at src/lib.rs:19:9: +assertion `left == right` failed + left: 5 + right: 10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch11-writing-automated-tests/output-only-01-show-output/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-01-show-output/src/lib.rs old mode 100755 new mode 100644 index 43c4c92..462d224 --- a/listings/ch11-writing-automated-tests/output-only-01-show-output/src/lib.rs +++ b/listings/ch11-writing-automated-tests/output-only-01-show-output/src/lib.rs @@ -1,5 +1,5 @@ pub fn prints_and_returns_10(a: i32) -> i32 { - println!("I got the value {}", a); + println!("I got the value {a}"); 10 } diff --git a/listings/ch11-writing-automated-tests/output-only-02-single-test/Cargo.lock b/listings/ch11-writing-automated-tests/output-only-02-single-test/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-02-single-test/Cargo.toml b/listings/ch11-writing-automated-tests/output-only-02-single-test/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-02-single-test/output.txt b/listings/ch11-writing-automated-tests/output-only-02-single-test/output.txt old mode 100755 new mode 100644 index f2da984..47e2a47 --- a/listings/ch11-writing-automated-tests/output-only-02-single-test/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-02-single-test/output.txt @@ -1,6 +1,6 @@ $ cargo test one_hundred Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.69s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.69s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/output-only-02-single-test/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-02-single-test/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/Cargo.lock b/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/Cargo.toml b/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/output.txt b/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/output.txt old mode 100755 new mode 100644 index 255a051..d08940a --- a/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/output.txt @@ -1,6 +1,6 @@ $ cargo test add Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.61s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.61s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 2 tests diff --git a/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-03-multiple-tests/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/Cargo.lock b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/Cargo.toml b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/output.txt b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/output.txt old mode 100755 new mode 100644 index b37868d..4c7782d --- a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/output.txt @@ -1,6 +1,6 @@ $ cargo test -- --ignored Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.61s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.61s Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4) running 1 test diff --git a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-05-single-integration/Cargo.lock b/listings/ch11-writing-automated-tests/output-only-05-single-integration/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-05-single-integration/Cargo.toml b/listings/ch11-writing-automated-tests/output-only-05-single-integration/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-05-single-integration/output.txt b/listings/ch11-writing-automated-tests/output-only-05-single-integration/output.txt old mode 100755 new mode 100644 index 260beaa..2745d0f --- a/listings/ch11-writing-automated-tests/output-only-05-single-integration/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-05-single-integration/output.txt @@ -1,6 +1,6 @@ $ cargo test --test integration_test Compiling adder v0.1.0 (file:///projects/adder) - Finished test [unoptimized + debuginfo] target(s) in 0.64s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.64s Running tests/integration_test.rs (target/debug/deps/integration_test-82e7799c1bc62298) running 1 test diff --git a/listings/ch11-writing-automated-tests/output-only-05-single-integration/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-05-single-integration/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch11-writing-automated-tests/output-only-05-single-integration/tests/integration_test.rs b/listings/ch11-writing-automated-tests/output-only-05-single-integration/tests/integration_test.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-01/Cargo.lock b/listings/ch12-an-io-project/listing-12-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-01/Cargo.toml b/listings/ch12-an-io-project/listing-12-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-01/output.txt b/listings/ch12-an-io-project/listing-12-01/output.txt old mode 100755 new mode 100644 index 529115f..d2abb05 --- a/listings/ch12-an-io-project/listing-12-01/output.txt +++ b/listings/ch12-an-io-project/listing-12-01/output.txt @@ -1,7 +1,7 @@ $ cargo run Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.61s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s Running `target/debug/minigrep` -[src/main.rs:5] args = [ +[src/main.rs:5:5] args = [ "target/debug/minigrep", ] diff --git a/listings/ch12-an-io-project/listing-12-01/src/main.rs b/listings/ch12-an-io-project/listing-12-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-02/Cargo.lock b/listings/ch12-an-io-project/listing-12-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-02/Cargo.toml b/listings/ch12-an-io-project/listing-12-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-02/output.txt b/listings/ch12-an-io-project/listing-12-02/output.txt old mode 100755 new mode 100644 index 6ef87f7..ad87dcf --- a/listings/ch12-an-io-project/listing-12-02/output.txt +++ b/listings/ch12-an-io-project/listing-12-02/output.txt @@ -1,6 +1,6 @@ $ cargo run -- test sample.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep test sample.txt` Searching for test In file sample.txt diff --git a/listings/ch12-an-io-project/listing-12-02/src/main.rs b/listings/ch12-an-io-project/listing-12-02/src/main.rs old mode 100755 new mode 100644 index ae2fa7b..afc3c3c --- a/listings/ch12-an-io-project/listing-12-02/src/main.rs +++ b/listings/ch12-an-io-project/listing-12-02/src/main.rs @@ -6,6 +6,6 @@ fn main() { let query = &args[1]; let file_path = &args[2]; - println!("Searching for {}", query); - println!("In file {}", file_path); + println!("Searching for {query}"); + println!("In file {file_path}"); } diff --git a/listings/ch12-an-io-project/listing-12-03/Cargo.lock b/listings/ch12-an-io-project/listing-12-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-03/Cargo.toml b/listings/ch12-an-io-project/listing-12-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-03/poem.txt b/listings/ch12-an-io-project/listing-12-03/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-03/src/main.rs b/listings/ch12-an-io-project/listing-12-03/src/main.rs old mode 100755 new mode 100644 index ae2fa7b..afc3c3c --- a/listings/ch12-an-io-project/listing-12-03/src/main.rs +++ b/listings/ch12-an-io-project/listing-12-03/src/main.rs @@ -6,6 +6,6 @@ fn main() { let query = &args[1]; let file_path = &args[2]; - println!("Searching for {}", query); - println!("In file {}", file_path); + println!("Searching for {query}"); + println!("In file {file_path}"); } diff --git a/listings/ch12-an-io-project/listing-12-04/Cargo.lock b/listings/ch12-an-io-project/listing-12-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-04/Cargo.toml b/listings/ch12-an-io-project/listing-12-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-04/output.txt b/listings/ch12-an-io-project/listing-12-04/output.txt old mode 100755 new mode 100644 index 6582ca1..d8cfe39 --- a/listings/ch12-an-io-project/listing-12-04/output.txt +++ b/listings/ch12-an-io-project/listing-12-04/output.txt @@ -1,6 +1,6 @@ $ cargo run -- the poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep the poem.txt` Searching for the In file poem.txt diff --git a/listings/ch12-an-io-project/listing-12-04/poem.txt b/listings/ch12-an-io-project/listing-12-04/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-04/src/main.rs b/listings/ch12-an-io-project/listing-12-04/src/main.rs old mode 100755 new mode 100644 index 944e430..f343249 --- a/listings/ch12-an-io-project/listing-12-04/src/main.rs +++ b/listings/ch12-an-io-project/listing-12-04/src/main.rs @@ -10,9 +10,9 @@ fn main() { let query = &args[1]; let file_path = &args[2]; - println!("Searching for {}", query); + println!("Searching for {query}"); // ANCHOR: here - println!("In file {}", file_path); + println!("In file {file_path}"); let contents = fs::read_to_string(file_path) .expect("Should have been able to read the file"); diff --git a/listings/ch12-an-io-project/listing-12-05/Cargo.lock b/listings/ch12-an-io-project/listing-12-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-05/Cargo.toml b/listings/ch12-an-io-project/listing-12-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-05/poem.txt b/listings/ch12-an-io-project/listing-12-05/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-05/src/main.rs b/listings/ch12-an-io-project/listing-12-05/src/main.rs old mode 100755 new mode 100644 index 0615918..838cacf --- a/listings/ch12-an-io-project/listing-12-05/src/main.rs +++ b/listings/ch12-an-io-project/listing-12-05/src/main.rs @@ -10,8 +10,8 @@ fn main() { // --snip-- // ANCHOR_END: here - println!("Searching for {}", query); - println!("In file {}", file_path); + println!("Searching for {query}"); + println!("In file {file_path}"); let contents = fs::read_to_string(file_path) .expect("Should have been able to read the file"); diff --git a/listings/ch12-an-io-project/listing-12-06/Cargo.lock b/listings/ch12-an-io-project/listing-12-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-06/Cargo.toml b/listings/ch12-an-io-project/listing-12-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-06/poem.txt b/listings/ch12-an-io-project/listing-12-06/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-06/src/main.rs b/listings/ch12-an-io-project/listing-12-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-07/Cargo.lock b/listings/ch12-an-io-project/listing-12-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-07/Cargo.toml b/listings/ch12-an-io-project/listing-12-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-07/output.txt b/listings/ch12-an-io-project/listing-12-07/output.txt old mode 100755 new mode 100644 index d3fa777..e14b954 --- a/listings/ch12-an-io-project/listing-12-07/output.txt +++ b/listings/ch12-an-io-project/listing-12-07/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep` -thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:27:21 +thread 'main' panicked at src/main.rs:27:21: +index out of bounds: the len is 1 but the index is 1 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-07/poem.txt b/listings/ch12-an-io-project/listing-12-07/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-07/src/main.rs b/listings/ch12-an-io-project/listing-12-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-08/Cargo.lock b/listings/ch12-an-io-project/listing-12-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-08/Cargo.toml b/listings/ch12-an-io-project/listing-12-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-08/output.txt b/listings/ch12-an-io-project/listing-12-08/output.txt old mode 100755 new mode 100644 index de2abd1..c1aa1a9 --- a/listings/ch12-an-io-project/listing-12-08/output.txt +++ b/listings/ch12-an-io-project/listing-12-08/output.txt @@ -1,6 +1,7 @@ $ cargo run Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep` -thread 'main' panicked at 'not enough arguments', src/main.rs:26:13 +thread 'main' panicked at src/main.rs:26:13: +not enough arguments note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-08/poem.txt b/listings/ch12-an-io-project/listing-12-08/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-08/src/main.rs b/listings/ch12-an-io-project/listing-12-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-09/Cargo.lock b/listings/ch12-an-io-project/listing-12-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-09/Cargo.toml b/listings/ch12-an-io-project/listing-12-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-09/poem.txt b/listings/ch12-an-io-project/listing-12-09/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-09/src/main.rs b/listings/ch12-an-io-project/listing-12-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-10/Cargo.lock b/listings/ch12-an-io-project/listing-12-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-10/Cargo.toml b/listings/ch12-an-io-project/listing-12-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-10/output.txt b/listings/ch12-an-io-project/listing-12-10/output.txt old mode 100755 new mode 100644 index 7aad57f..c5e085b --- a/listings/ch12-an-io-project/listing-12-10/output.txt +++ b/listings/ch12-an-io-project/listing-12-10/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.48s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `target/debug/minigrep` Problem parsing arguments: not enough arguments diff --git a/listings/ch12-an-io-project/listing-12-10/poem.txt b/listings/ch12-an-io-project/listing-12-10/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-10/src/main.rs b/listings/ch12-an-io-project/listing-12-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-11/Cargo.lock b/listings/ch12-an-io-project/listing-12-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-11/Cargo.toml b/listings/ch12-an-io-project/listing-12-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-11/poem.txt b/listings/ch12-an-io-project/listing-12-11/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-11/src/main.rs b/listings/ch12-an-io-project/listing-12-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-12/Cargo.lock b/listings/ch12-an-io-project/listing-12-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-12/Cargo.toml b/listings/ch12-an-io-project/listing-12-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-12/output.txt b/listings/ch12-an-io-project/listing-12-12/output.txt old mode 100755 new mode 100644 index c189025..6c5e67b --- a/listings/ch12-an-io-project/listing-12-12/output.txt +++ b/listings/ch12-an-io-project/listing-12-12/output.txt @@ -1,16 +1,20 @@ -$ cargo run the poem.txt +$ cargo run -- the poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) warning: unused `Result` that must be used --> src/main.rs:19:5 | 19 | run(config); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^ | - = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled + = note: `#[warn(unused_must_use)]` on by default +help: use `let _ = ...` to ignore the resulting value + | +19 | let _ = run(config); + | +++++++ warning: `minigrep` (bin "minigrep") generated 1 warning - Finished dev [unoptimized + debuginfo] target(s) in 0.71s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.71s Running `target/debug/minigrep the poem.txt` Searching for the In file poem.txt diff --git a/listings/ch12-an-io-project/listing-12-12/poem.txt b/listings/ch12-an-io-project/listing-12-12/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-12/src/main.rs b/listings/ch12-an-io-project/listing-12-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-13/Cargo.lock b/listings/ch12-an-io-project/listing-12-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-13/Cargo.toml b/listings/ch12-an-io-project/listing-12-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-13/poem.txt b/listings/ch12-an-io-project/listing-12-13/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-13/src/lib.rs b/listings/ch12-an-io-project/listing-12-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-13/src/main.rs b/listings/ch12-an-io-project/listing-12-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-14/Cargo.lock b/listings/ch12-an-io-project/listing-12-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-14/Cargo.toml b/listings/ch12-an-io-project/listing-12-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-14/poem.txt b/listings/ch12-an-io-project/listing-12-14/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-14/src/lib.rs b/listings/ch12-an-io-project/listing-12-14/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-14/src/main.rs b/listings/ch12-an-io-project/listing-12-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-15/Cargo.lock b/listings/ch12-an-io-project/listing-12-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-15/Cargo.toml b/listings/ch12-an-io-project/listing-12-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-15/poem.txt b/listings/ch12-an-io-project/listing-12-15/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-15/src/lib.rs b/listings/ch12-an-io-project/listing-12-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-15/src/main.rs b/listings/ch12-an-io-project/listing-12-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-16/Cargo.lock b/listings/ch12-an-io-project/listing-12-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-16/Cargo.toml b/listings/ch12-an-io-project/listing-12-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-16/output.txt b/listings/ch12-an-io-project/listing-12-16/output.txt old mode 100755 new mode 100644 index 3c34e39..9f4c64d --- a/listings/ch12-an-io-project/listing-12-16/output.txt +++ b/listings/ch12-an-io-project/listing-12-16/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished test [unoptimized + debuginfo] target(s) in 0.97s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.97s Running unittests src/lib.rs (target/debug/deps/minigrep-9cd200e5fac0fc94) running 1 test @@ -9,9 +9,10 @@ test tests::one_result ... FAILED failures: ---- tests::one_result stdout ---- -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `["safe, fast, productive."]`, - right: `[]`', src/lib.rs:44:9 +thread 'tests::one_result' panicked at src/lib.rs:44:9: +assertion `left == right` failed + left: ["safe, fast, productive."] + right: [] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-16/poem.txt b/listings/ch12-an-io-project/listing-12-16/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-16/src/lib.rs b/listings/ch12-an-io-project/listing-12-16/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-16/src/main.rs b/listings/ch12-an-io-project/listing-12-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-17/Cargo.lock b/listings/ch12-an-io-project/listing-12-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-17/Cargo.toml b/listings/ch12-an-io-project/listing-12-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-17/poem.txt b/listings/ch12-an-io-project/listing-12-17/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-17/src/lib.rs b/listings/ch12-an-io-project/listing-12-17/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-17/src/main.rs b/listings/ch12-an-io-project/listing-12-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-18/Cargo.lock b/listings/ch12-an-io-project/listing-12-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-18/Cargo.toml b/listings/ch12-an-io-project/listing-12-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-18/poem.txt b/listings/ch12-an-io-project/listing-12-18/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-18/src/lib.rs b/listings/ch12-an-io-project/listing-12-18/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-18/src/main.rs b/listings/ch12-an-io-project/listing-12-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-19/Cargo.lock b/listings/ch12-an-io-project/listing-12-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-19/Cargo.toml b/listings/ch12-an-io-project/listing-12-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-19/output.txt b/listings/ch12-an-io-project/listing-12-19/output.txt old mode 100755 new mode 100644 index 9b2078c..ed87e4f --- a/listings/ch12-an-io-project/listing-12-19/output.txt +++ b/listings/ch12-an-io-project/listing-12-19/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished test [unoptimized + debuginfo] target(s) in 1.22s + Finished `test` profile [unoptimized + debuginfo] target(s) in 1.22s Running unittests src/lib.rs (target/debug/deps/minigrep-9cd200e5fac0fc94) running 1 test diff --git a/listings/ch12-an-io-project/listing-12-19/poem.txt b/listings/ch12-an-io-project/listing-12-19/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-19/src/lib.rs b/listings/ch12-an-io-project/listing-12-19/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-19/src/main.rs b/listings/ch12-an-io-project/listing-12-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-20/Cargo.lock b/listings/ch12-an-io-project/listing-12-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-20/Cargo.toml b/listings/ch12-an-io-project/listing-12-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-20/poem.txt b/listings/ch12-an-io-project/listing-12-20/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-20/src/lib.rs b/listings/ch12-an-io-project/listing-12-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-20/src/main.rs b/listings/ch12-an-io-project/listing-12-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-21/Cargo.lock b/listings/ch12-an-io-project/listing-12-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-21/Cargo.toml b/listings/ch12-an-io-project/listing-12-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-21/output.txt b/listings/ch12-an-io-project/listing-12-21/output.txt old mode 100755 new mode 100644 index dafeb78..945df3f --- a/listings/ch12-an-io-project/listing-12-21/output.txt +++ b/listings/ch12-an-io-project/listing-12-21/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished test [unoptimized + debuginfo] target(s) in 1.33s + Finished `test` profile [unoptimized + debuginfo] target(s) in 1.33s Running unittests src/lib.rs (target/debug/deps/minigrep-9cd200e5fac0fc94) running 2 tests diff --git a/listings/ch12-an-io-project/listing-12-21/poem.txt b/listings/ch12-an-io-project/listing-12-21/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-21/src/lib.rs b/listings/ch12-an-io-project/listing-12-21/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-21/src/main.rs b/listings/ch12-an-io-project/listing-12-21/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-22/Cargo.lock b/listings/ch12-an-io-project/listing-12-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-22/Cargo.toml b/listings/ch12-an-io-project/listing-12-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-22/poem.txt b/listings/ch12-an-io-project/listing-12-22/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-22/src/lib.rs b/listings/ch12-an-io-project/listing-12-22/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-22/src/main.rs b/listings/ch12-an-io-project/listing-12-22/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-23/Cargo.lock b/listings/ch12-an-io-project/listing-12-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-23/Cargo.toml b/listings/ch12-an-io-project/listing-12-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-23/output.txt b/listings/ch12-an-io-project/listing-12-23/output.txt old mode 100755 new mode 100644 index eaffc2f..5c6fc0c --- a/listings/ch12-an-io-project/listing-12-23/output.txt +++ b/listings/ch12-an-io-project/listing-12-23/output.txt @@ -1,6 +1,6 @@ $ cargo run -- to poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep to poem.txt` Are you nobody, too? How dreary to be somebody! diff --git a/listings/ch12-an-io-project/listing-12-23/poem.txt b/listings/ch12-an-io-project/listing-12-23/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-23/src/lib.rs b/listings/ch12-an-io-project/listing-12-23/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-23/src/main.rs b/listings/ch12-an-io-project/listing-12-23/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-24/Cargo.lock b/listings/ch12-an-io-project/listing-12-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-24/Cargo.toml b/listings/ch12-an-io-project/listing-12-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-24/poem.txt b/listings/ch12-an-io-project/listing-12-24/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-24/src/lib.rs b/listings/ch12-an-io-project/listing-12-24/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/listing-12-24/src/main.rs b/listings/ch12-an-io-project/listing-12-24/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/Cargo.lock b/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/Cargo.toml b/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/poem.txt b/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/src/main.rs b/listings/ch12-an-io-project/no-listing-01-handling-errors-in-main/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/Cargo.lock b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/Cargo.toml b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/output.txt b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/output.txt old mode 100755 new mode 100644 index a5a4ef8..44b2036 --- a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/output.txt +++ b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/output.txt @@ -1,5 +1,5 @@ $ cargo run -- frog poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.38s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.38s Running `target/debug/minigrep frog poem.txt` How public, like a frog diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/poem.txt b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/src/lib.rs b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/no-listing-02-using-search-in-run/src/main.rs b/listings/ch12-an-io-project/no-listing-02-using-search-in-run/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-01-with-args/Cargo.lock b/listings/ch12-an-io-project/output-only-01-with-args/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-01-with-args/Cargo.toml b/listings/ch12-an-io-project/output-only-01-with-args/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-01-with-args/output.txt b/listings/ch12-an-io-project/output-only-01-with-args/output.txt old mode 100755 new mode 100644 index b48bb0e..5f733a7 --- a/listings/ch12-an-io-project/output-only-01-with-args/output.txt +++ b/listings/ch12-an-io-project/output-only-01-with-args/output.txt @@ -1,8 +1,8 @@ $ cargo run -- needle haystack Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 1.57s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s Running `target/debug/minigrep needle haystack` -[src/main.rs:5] args = [ +[src/main.rs:5:5] args = [ "target/debug/minigrep", "needle", "haystack", diff --git a/listings/ch12-an-io-project/output-only-01-with-args/src/main.rs b/listings/ch12-an-io-project/output-only-01-with-args/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/Cargo.lock b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/Cargo.toml b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt old mode 100755 new mode 100644 index 93116dd..7e46576 --- a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt +++ b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt @@ -13,4 +13,4 @@ help: consider introducing a named lifetime parameter | ++++ ++ ++ ++ For more information about this error, try `rustc --explain E0106`. -error: could not compile `minigrep` due to previous error +error: could not compile `minigrep` (lib) due to 1 previous error diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/poem.txt b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/main.rs b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/Cargo.lock b/listings/ch12-an-io-project/output-only-03-multiple-matches/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/Cargo.toml b/listings/ch12-an-io-project/output-only-03-multiple-matches/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/output.txt b/listings/ch12-an-io-project/output-only-03-multiple-matches/output.txt old mode 100755 new mode 100644 index b468357..704df25 --- a/listings/ch12-an-io-project/output-only-03-multiple-matches/output.txt +++ b/listings/ch12-an-io-project/output-only-03-multiple-matches/output.txt @@ -1,6 +1,6 @@ $ cargo run -- body poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep body poem.txt` I'm nobody! Who are you? Are you nobody, too? diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/poem.txt b/listings/ch12-an-io-project/output-only-03-multiple-matches/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/src/lib.rs b/listings/ch12-an-io-project/output-only-03-multiple-matches/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-03-multiple-matches/src/main.rs b/listings/ch12-an-io-project/output-only-03-multiple-matches/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/Cargo.lock b/listings/ch12-an-io-project/output-only-04-no-matches/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/Cargo.toml b/listings/ch12-an-io-project/output-only-04-no-matches/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/output.txt b/listings/ch12-an-io-project/output-only-04-no-matches/output.txt old mode 100755 new mode 100644 index a53624f..57f3a61 --- a/listings/ch12-an-io-project/output-only-04-no-matches/output.txt +++ b/listings/ch12-an-io-project/output-only-04-no-matches/output.txt @@ -1,4 +1,4 @@ $ cargo run -- monomorphization poem.txt Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep monomorphization poem.txt` diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/poem.txt b/listings/ch12-an-io-project/output-only-04-no-matches/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/src/lib.rs b/listings/ch12-an-io-project/output-only-04-no-matches/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch12-an-io-project/output-only-04-no-matches/src/main.rs b/listings/ch12-an-io-project/output-only-04-no-matches/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/Cargo.lock b/listings/ch13-functional-features/listing-12-23-reproduced/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/Cargo.toml b/listings/ch13-functional-features/listing-12-23-reproduced/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/poem.txt b/listings/ch13-functional-features/listing-12-23-reproduced/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs b/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/src/main.rs b/listings/ch13-functional-features/listing-12-23-reproduced/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-24-reproduced/Cargo.lock b/listings/ch13-functional-features/listing-12-24-reproduced/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-24-reproduced/Cargo.toml b/listings/ch13-functional-features/listing-12-24-reproduced/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-24-reproduced/poem.txt b/listings/ch13-functional-features/listing-12-24-reproduced/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-24-reproduced/src/lib.rs b/listings/ch13-functional-features/listing-12-24-reproduced/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-12-24-reproduced/src/main.rs b/listings/ch13-functional-features/listing-12-24-reproduced/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-01/Cargo.lock b/listings/ch13-functional-features/listing-13-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-01/Cargo.toml b/listings/ch13-functional-features/listing-13-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-01/output.txt b/listings/ch13-functional-features/listing-13-01/output.txt old mode 100755 new mode 100644 index b64a4d8..28c829f --- a/listings/ch13-functional-features/listing-13-01/output.txt +++ b/listings/ch13-functional-features/listing-13-01/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling shirt-company v0.1.0 (file:///projects/shirt-company) - Finished dev [unoptimized + debuginfo] target(s) in 0.27s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/shirt-company` The user with preference Some(Red) gets Red The user with preference None gets Blue diff --git a/listings/ch13-functional-features/listing-13-01/src/main.rs b/listings/ch13-functional-features/listing-13-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-02/Cargo.lock b/listings/ch13-functional-features/listing-13-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-02/Cargo.toml b/listings/ch13-functional-features/listing-13-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-02/src/main.rs b/listings/ch13-functional-features/listing-13-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-03/Cargo.lock b/listings/ch13-functional-features/listing-13-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-03/Cargo.toml b/listings/ch13-functional-features/listing-13-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-03/output.txt b/listings/ch13-functional-features/listing-13-03/output.txt old mode 100755 new mode 100644 index 68838de..16716c3 --- a/listings/ch13-functional-features/listing-13-03/output.txt +++ b/listings/ch13-functional-features/listing-13-03/output.txt @@ -6,9 +6,16 @@ error[E0308]: mismatched types 5 | let n = example_closure(5); | --------------- ^- help: try using a conversion method: `.to_string()` | | | - | | expected struct `String`, found integer + | | expected `String`, found integer | arguments to this function are incorrect | +note: expected because the closure was earlier called with an argument of type `String` + --> src/main.rs:4:29 + | +4 | let s = example_closure(String::from("hello")); + | --------------- ^^^^^^^^^^^^^^^^^^^^^ expected because this argument is of type `String` + | | + | in this closure call note: closure parameter defined here --> src/main.rs:2:28 | @@ -16,4 +23,4 @@ note: closure parameter defined here | ^ For more information about this error, try `rustc --explain E0308`. -error: could not compile `closure-example` due to previous error +error: could not compile `closure-example` (bin "closure-example") due to 1 previous error diff --git a/listings/ch13-functional-features/listing-13-03/src/main.rs b/listings/ch13-functional-features/listing-13-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-04/Cargo.lock b/listings/ch13-functional-features/listing-13-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-04/Cargo.toml b/listings/ch13-functional-features/listing-13-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-04/output.txt b/listings/ch13-functional-features/listing-13-04/output.txt old mode 100755 new mode 100644 index 64d763b..fd33cb7 --- a/listings/ch13-functional-features/listing-13-04/output.txt +++ b/listings/ch13-functional-features/listing-13-04/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling closure-example v0.1.0 (file:///projects/closure-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.43s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/closure-example` Before defining closure: [1, 2, 3] Before calling closure: [1, 2, 3] diff --git a/listings/ch13-functional-features/listing-13-04/src/main.rs b/listings/ch13-functional-features/listing-13-04/src/main.rs old mode 100755 new mode 100644 index 43b91bb..19f51a6 --- a/listings/ch13-functional-features/listing-13-04/src/main.rs +++ b/listings/ch13-functional-features/listing-13-04/src/main.rs @@ -1,10 +1,10 @@ fn main() { let list = vec![1, 2, 3]; - println!("Before defining closure: {:?}", list); + println!("Before defining closure: {list:?}"); - let only_borrows = || println!("From closure: {:?}", list); + let only_borrows = || println!("From closure: {list:?}"); - println!("Before calling closure: {:?}", list); + println!("Before calling closure: {list:?}"); only_borrows(); - println!("After calling closure: {:?}", list); + println!("After calling closure: {list:?}"); } diff --git a/listings/ch13-functional-features/listing-13-05/Cargo.lock b/listings/ch13-functional-features/listing-13-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-05/Cargo.toml b/listings/ch13-functional-features/listing-13-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-05/output.txt b/listings/ch13-functional-features/listing-13-05/output.txt old mode 100755 new mode 100644 index ce0ad5e..af22182 --- a/listings/ch13-functional-features/listing-13-05/output.txt +++ b/listings/ch13-functional-features/listing-13-05/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling closure-example v0.1.0 (file:///projects/closure-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.43s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/closure-example` Before defining closure: [1, 2, 3] After calling closure: [1, 2, 3, 7] diff --git a/listings/ch13-functional-features/listing-13-05/src/main.rs b/listings/ch13-functional-features/listing-13-05/src/main.rs old mode 100755 new mode 100644 index 37f8130..f6c2a53 --- a/listings/ch13-functional-features/listing-13-05/src/main.rs +++ b/listings/ch13-functional-features/listing-13-05/src/main.rs @@ -1,9 +1,9 @@ fn main() { let mut list = vec![1, 2, 3]; - println!("Before defining closure: {:?}", list); + println!("Before defining closure: {list:?}"); let mut borrows_mutably = || list.push(7); borrows_mutably(); - println!("After calling closure: {:?}", list); + println!("After calling closure: {list:?}"); } diff --git a/listings/ch13-functional-features/listing-13-06/Cargo.lock b/listings/ch13-functional-features/listing-13-06/Cargo.lock deleted file mode 100755 index 75ff09e..0000000 --- a/listings/ch13-functional-features/listing-13-06/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "workout-app" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-06/Cargo.toml b/listings/ch13-functional-features/listing-13-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-06/src/main.rs b/listings/ch13-functional-features/listing-13-06/src/main.rs old mode 100755 new mode 100644 index 2c8e18c..ee9ca04 --- a/listings/ch13-functional-features/listing-13-06/src/main.rs +++ b/listings/ch13-functional-features/listing-13-06/src/main.rs @@ -2,9 +2,9 @@ use std::thread; fn main() { let list = vec![1, 2, 3]; - println!("Before defining closure: {:?}", list); + println!("Before defining closure: {list:?}"); - thread::spawn(move || println!("From thread: {:?}", list)) + thread::spawn(move || println!("From thread: {list:?}")) .join() .unwrap(); } diff --git a/listings/ch13-functional-features/listing-13-07/.rustfmt.toml b/listings/ch13-functional-features/listing-13-07/.rustfmt.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-07/Cargo.lock b/listings/ch13-functional-features/listing-13-07/Cargo.lock deleted file mode 100755 index 75ff09e..0000000 --- a/listings/ch13-functional-features/listing-13-07/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "workout-app" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-07/Cargo.toml b/listings/ch13-functional-features/listing-13-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-07/output.txt b/listings/ch13-functional-features/listing-13-07/output.txt old mode 100755 new mode 100644 index f18fce4..8c11d84 --- a/listings/ch13-functional-features/listing-13-07/output.txt +++ b/listings/ch13-functional-features/listing-13-07/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling rectangles v0.1.0 (file:///projects/rectangles) - Finished dev [unoptimized + debuginfo] target(s) in 0.41s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s Running `target/debug/rectangles` [ Rectangle { diff --git a/listings/ch13-functional-features/listing-13-07/src/main.rs b/listings/ch13-functional-features/listing-13-07/src/main.rs old mode 100755 new mode 100644 index 73a25e5..e7ab8d3 --- a/listings/ch13-functional-features/listing-13-07/src/main.rs +++ b/listings/ch13-functional-features/listing-13-07/src/main.rs @@ -12,5 +12,5 @@ fn main() { ]; list.sort_by_key(|r| r.width); - println!("{:#?}", list); + println!("{list:#?}"); } diff --git a/listings/ch13-functional-features/listing-13-08/.rustfmt.toml b/listings/ch13-functional-features/listing-13-08/.rustfmt.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-08/Cargo.lock b/listings/ch13-functional-features/listing-13-08/Cargo.lock deleted file mode 100755 index c190d3a..0000000 --- a/listings/ch13-functional-features/listing-13-08/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "closure-example" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-08/Cargo.toml b/listings/ch13-functional-features/listing-13-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-08/output.txt b/listings/ch13-functional-features/listing-13-08/output.txt old mode 100755 new mode 100644 index a910537..7f5ce88 --- a/listings/ch13-functional-features/listing-13-08/output.txt +++ b/listings/ch13-functional-features/listing-13-08/output.txt @@ -3,7 +3,7 @@ $ cargo run error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` closure --> src/main.rs:18:30 | -15 | let value = String::from("by key called"); +15 | let value = String::from("closure called"); | ----- captured outer variable 16 | 17 | list.sort_by_key(|r| { @@ -12,4 +12,4 @@ error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` clos | ^^^^^ move occurs because `value` has type `String`, which does not implement the `Copy` trait For more information about this error, try `rustc --explain E0507`. -error: could not compile `rectangles` due to previous error +error: could not compile `rectangles` (bin "rectangles") due to 1 previous error diff --git a/listings/ch13-functional-features/listing-13-08/src/main.rs b/listings/ch13-functional-features/listing-13-08/src/main.rs old mode 100755 new mode 100644 index 3b9c9cb..e00fec7 --- a/listings/ch13-functional-features/listing-13-08/src/main.rs +++ b/listings/ch13-functional-features/listing-13-08/src/main.rs @@ -12,11 +12,11 @@ fn main() { ]; let mut sort_operations = vec![]; - let value = String::from("by key called"); + let value = String::from("closure called"); list.sort_by_key(|r| { sort_operations.push(value); r.width }); - println!("{:#?}", list); + println!("{list:#?}"); } diff --git a/listings/ch13-functional-features/listing-13-09/.rustfmt.toml b/listings/ch13-functional-features/listing-13-09/.rustfmt.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-09/Cargo.lock b/listings/ch13-functional-features/listing-13-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-09/Cargo.toml b/listings/ch13-functional-features/listing-13-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-09/src/main.rs b/listings/ch13-functional-features/listing-13-09/src/main.rs old mode 100755 new mode 100644 index a60d6fd..f007e3c --- a/listings/ch13-functional-features/listing-13-09/src/main.rs +++ b/listings/ch13-functional-features/listing-13-09/src/main.rs @@ -16,5 +16,5 @@ fn main() { num_sort_operations += 1; r.width }); - println!("{:#?}, sorted in {num_sort_operations} operations", list); + println!("{list:#?}, sorted in {num_sort_operations} operations"); } diff --git a/listings/ch13-functional-features/listing-13-10/Cargo.lock b/listings/ch13-functional-features/listing-13-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-10/Cargo.toml b/listings/ch13-functional-features/listing-13-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-10/src/main.rs b/listings/ch13-functional-features/listing-13-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-11/Cargo.lock b/listings/ch13-functional-features/listing-13-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-11/Cargo.toml b/listings/ch13-functional-features/listing-13-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-11/src/main.rs b/listings/ch13-functional-features/listing-13-11/src/main.rs old mode 100755 new mode 100644 index 712aff4..b4e8516 --- a/listings/ch13-functional-features/listing-13-11/src/main.rs +++ b/listings/ch13-functional-features/listing-13-11/src/main.rs @@ -5,7 +5,7 @@ fn main() { let v1_iter = v1.iter(); for val in v1_iter { - println!("Got: {}", val); + println!("Got: {val}"); } // ANCHOR_END: here } diff --git a/listings/ch13-functional-features/listing-13-12/Cargo.lock b/listings/ch13-functional-features/listing-13-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-12/Cargo.toml b/listings/ch13-functional-features/listing-13-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-12/src/lib.rs b/listings/ch13-functional-features/listing-13-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-12/src/main.rs b/listings/ch13-functional-features/listing-13-12/src/main.rs deleted file mode 100755 index 7352b80..0000000 --- a/listings/ch13-functional-features/listing-13-12/src/main.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - let x = 4; - - let equal_to_x = |z| z == x; - - let y = 4; - - assert!(equal_to_x(y)); -} diff --git a/listings/ch13-functional-features/listing-13-13/Cargo.lock b/listings/ch13-functional-features/listing-13-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-13/Cargo.toml b/listings/ch13-functional-features/listing-13-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-13/src/lib.rs b/listings/ch13-functional-features/listing-13-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-13/src/main.rs b/listings/ch13-functional-features/listing-13-13/src/main.rs deleted file mode 100755 index 55a0dd3..0000000 --- a/listings/ch13-functional-features/listing-13-13/src/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - // ANCHOR: here - let v1 = vec![1, 2, 3]; - - let v1_iter = v1.iter(); - // ANCHOR_END: here -} diff --git a/listings/ch13-functional-features/listing-13-14/Cargo.lock b/listings/ch13-functional-features/listing-13-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-14/Cargo.toml b/listings/ch13-functional-features/listing-13-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-14/output.txt b/listings/ch13-functional-features/listing-13-14/output.txt old mode 100755 new mode 100644 index 228c764..d46dd5c --- a/listings/ch13-functional-features/listing-13-14/output.txt +++ b/listings/ch13-functional-features/listing-13-14/output.txt @@ -4,11 +4,15 @@ warning: unused `Map` that must be used --> src/main.rs:4:5 | 4 | v1.iter().map(|x| x + 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unused_must_use)]` on by default = note: iterators are lazy and do nothing unless consumed + = note: `#[warn(unused_must_use)]` on by default +help: use `let _ = ...` to ignore the resulting value + | +4 | let _ = v1.iter().map(|x| x + 1); + | +++++++ warning: `iterators` (bin "iterators") generated 1 warning - Finished dev [unoptimized + debuginfo] target(s) in 0.47s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.47s Running `target/debug/iterators` diff --git a/listings/ch13-functional-features/listing-13-14/src/main.rs b/listings/ch13-functional-features/listing-13-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-15/Cargo.lock b/listings/ch13-functional-features/listing-13-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-15/Cargo.toml b/listings/ch13-functional-features/listing-13-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-15/src/lib.rs b/listings/ch13-functional-features/listing-13-15/src/lib.rs deleted file mode 100755 index 7582840..0000000 --- a/listings/ch13-functional-features/listing-13-15/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[cfg(test)] -mod tests { - // ANCHOR: here - #[test] - fn iterator_demonstration() { - let v1 = vec![1, 2, 3]; - - let mut v1_iter = v1.iter(); - - assert_eq!(v1_iter.next(), Some(&1)); - assert_eq!(v1_iter.next(), Some(&2)); - assert_eq!(v1_iter.next(), Some(&3)); - assert_eq!(v1_iter.next(), None); - } - // ANCHOR_END: here -} diff --git a/listings/ch13-functional-features/listing-13-15/src/main.rs b/listings/ch13-functional-features/listing-13-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-16/Cargo.lock b/listings/ch13-functional-features/listing-13-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-16/Cargo.toml b/listings/ch13-functional-features/listing-13-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-16/src/lib.rs b/listings/ch13-functional-features/listing-13-16/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-17/Cargo.lock b/listings/ch13-functional-features/listing-13-17/Cargo.lock deleted file mode 100755 index e91eaa8..0000000 --- a/listings/ch13-functional-features/listing-13-17/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "iterators" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-17/Cargo.toml b/listings/ch13-functional-features/listing-13-17/Cargo.toml deleted file mode 100755 index 2652a8a..0000000 --- a/listings/ch13-functional-features/listing-13-17/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "iterators" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-17/output.txt b/listings/ch13-functional-features/listing-13-17/output.txt deleted file mode 100755 index 228c764..0000000 --- a/listings/ch13-functional-features/listing-13-17/output.txt +++ /dev/null @@ -1,14 +0,0 @@ -$ cargo run - Compiling iterators v0.1.0 (file:///projects/iterators) -warning: unused `Map` that must be used - --> src/main.rs:4:5 - | -4 | v1.iter().map(|x| x + 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unused_must_use)]` on by default - = note: iterators are lazy and do nothing unless consumed - -warning: `iterators` (bin "iterators") generated 1 warning - Finished dev [unoptimized + debuginfo] target(s) in 0.47s - Running `target/debug/iterators` diff --git a/listings/ch13-functional-features/listing-13-17/src/main.rs b/listings/ch13-functional-features/listing-13-17/src/main.rs deleted file mode 100755 index 62a68be..0000000 --- a/listings/ch13-functional-features/listing-13-17/src/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - // ANCHOR: here - let v1: Vec = vec![1, 2, 3]; - - v1.iter().map(|x| x + 1); - // ANCHOR_END: here -} diff --git a/listings/ch13-functional-features/listing-13-18/Cargo.lock b/listings/ch13-functional-features/listing-13-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-18/Cargo.toml b/listings/ch13-functional-features/listing-13-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-18/poem.txt b/listings/ch13-functional-features/listing-13-18/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-18/src/lib.rs b/listings/ch13-functional-features/listing-13-18/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-18/src/main.rs b/listings/ch13-functional-features/listing-13-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-19/Cargo.lock b/listings/ch13-functional-features/listing-13-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-19/Cargo.toml b/listings/ch13-functional-features/listing-13-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-19/poem.txt b/listings/ch13-functional-features/listing-13-19/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-19/src/lib.rs b/listings/ch13-functional-features/listing-13-19/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-19/src/main.rs b/listings/ch13-functional-features/listing-13-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-20/Cargo.lock b/listings/ch13-functional-features/listing-13-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-20/Cargo.toml b/listings/ch13-functional-features/listing-13-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-20/poem.txt b/listings/ch13-functional-features/listing-13-20/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-20/src/lib.rs b/listings/ch13-functional-features/listing-13-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-20/src/main.rs b/listings/ch13-functional-features/listing-13-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-21/Cargo.lock b/listings/ch13-functional-features/listing-13-21/Cargo.lock deleted file mode 100755 index 58b70c5..0000000 --- a/listings/ch13-functional-features/listing-13-21/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "counter" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-21/Cargo.toml b/listings/ch13-functional-features/listing-13-21/Cargo.toml deleted file mode 100755 index 9e103f3..0000000 --- a/listings/ch13-functional-features/listing-13-21/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "counter" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-21/src/lib.rs b/listings/ch13-functional-features/listing-13-21/src/lib.rs deleted file mode 100755 index 35ea8e5..0000000 --- a/listings/ch13-functional-features/listing-13-21/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -struct Counter { - count: u32, -} - -impl Counter { - fn new() -> Counter { - Counter { count: 0 } - } -} - -// ANCHOR: here -impl Iterator for Counter { - type Item = u32; - - fn next(&mut self) -> Option { - if self.count < 5 { - self.count += 1; - Some(self.count) - } else { - None - } - } -} -// ANCHOR_END: here diff --git a/listings/ch13-functional-features/listing-13-22/Cargo.lock b/listings/ch13-functional-features/listing-13-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-22/Cargo.toml b/listings/ch13-functional-features/listing-13-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-22/poem.txt b/listings/ch13-functional-features/listing-13-22/poem.txt old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-22/src/lib.rs b/listings/ch13-functional-features/listing-13-22/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-22/src/main.rs b/listings/ch13-functional-features/listing-13-22/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch13-functional-features/listing-13-23/Cargo.lock b/listings/ch13-functional-features/listing-13-23/Cargo.lock deleted file mode 100755 index 58b70c5..0000000 --- a/listings/ch13-functional-features/listing-13-23/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "counter" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-23/Cargo.toml b/listings/ch13-functional-features/listing-13-23/Cargo.toml deleted file mode 100755 index 9e103f3..0000000 --- a/listings/ch13-functional-features/listing-13-23/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "counter" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-23/src/lib.rs b/listings/ch13-functional-features/listing-13-23/src/lib.rs deleted file mode 100755 index f04d730..0000000 --- a/listings/ch13-functional-features/listing-13-23/src/lib.rs +++ /dev/null @@ -1,51 +0,0 @@ -struct Counter { - count: u32, -} - -impl Counter { - fn new() -> Counter { - Counter { count: 0 } - } -} - -impl Iterator for Counter { - type Item = u32; - - fn next(&mut self) -> Option { - if self.count < 5 { - self.count += 1; - Some(self.count) - } else { - None - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn calling_next_directly() { - let mut counter = Counter::new(); - - assert_eq!(counter.next(), Some(1)); - assert_eq!(counter.next(), Some(2)); - assert_eq!(counter.next(), Some(3)); - assert_eq!(counter.next(), Some(4)); - assert_eq!(counter.next(), Some(5)); - assert_eq!(counter.next(), None); - } - - // ANCHOR: here - #[test] - fn using_other_iterator_trait_methods() { - let sum: u32 = Counter::new() - .zip(Counter::new().skip(1)) - .map(|(a, b)| a * b) - .filter(|x| x % 3 == 0) - .sum(); - assert_eq!(18, sum); - } - // ANCHOR_END: here -} diff --git a/listings/ch13-functional-features/listing-13-25/Cargo.lock b/listings/ch13-functional-features/listing-13-25/Cargo.lock deleted file mode 100755 index 88bf82d..0000000 --- a/listings/ch13-functional-features/listing-13-25/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "minigrep" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-25/Cargo.toml b/listings/ch13-functional-features/listing-13-25/Cargo.toml deleted file mode 100755 index 64c2a3f..0000000 --- a/listings/ch13-functional-features/listing-13-25/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "minigrep" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-25/poem.txt b/listings/ch13-functional-features/listing-13-25/poem.txt deleted file mode 100755 index 8707527..0000000 --- a/listings/ch13-functional-features/listing-13-25/poem.txt +++ /dev/null @@ -1,9 +0,0 @@ -I'm nobody! Who are you? -Are you nobody, too? -Then there's a pair of us - don't tell! -They'd banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! diff --git a/listings/ch13-functional-features/listing-13-25/src/lib.rs b/listings/ch13-functional-features/listing-13-25/src/lib.rs deleted file mode 100755 index fe1dccf..0000000 --- a/listings/ch13-functional-features/listing-13-25/src/lib.rs +++ /dev/null @@ -1,104 +0,0 @@ -use std::env; -use std::error::Error; -use std::fs; - -pub struct Config { - pub query: String, - pub filename: String, - pub case_sensitive: bool, -} - -impl Config { - pub fn new(args: &[String]) -> Result { - if args.len() < 3 { - return Err("not enough arguments"); - } - - let query = args[1].clone(); - let filename = args[2].clone(); - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { - query, - filename, - case_sensitive, - }) - } -} - -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - let results = if config.case_sensitive { - search(&config.query, &contents) - } else { - search_case_insensitive(&config.query, &contents) - }; - - for line in results { - println!("{}", line); - } - - Ok(()) -} - -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let mut results = Vec::new(); - - for line in contents.lines() { - if line.contains(query) { - results.push(line); - } - } - - results -} - -pub fn search_case_insensitive<'a>( - query: &str, - contents: &'a str, -) -> Vec<&'a str> { - let query = query.to_lowercase(); - let mut results = Vec::new(); - - for line in contents.lines() { - if line.to_lowercase().contains(&query) { - results.push(line); - } - } - - results -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn case_sensitive() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Duct tape."; - - assert_eq!(vec!["safe, fast, productive."], search(query, contents)); - } - - #[test] - fn case_insensitive() { - let query = "rUsT"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Trust me."; - - assert_eq!( - vec!["Rust:", "Trust me."], - search_case_insensitive(query, contents) - ); - } -} diff --git a/listings/ch13-functional-features/listing-13-25/src/main.rs b/listings/ch13-functional-features/listing-13-25/src/main.rs deleted file mode 100755 index d09966e..0000000 --- a/listings/ch13-functional-features/listing-13-25/src/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::env; -use std::process; - -use minigrep::Config; - -// ANCHOR: here -fn main() { - let config = Config::new(env::args()).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - // --snip-- - // ANCHOR_END: here - - if let Err(e) = minigrep::run(config) { - eprintln!("Application error: {}", e); - - process::exit(1); - } - // ANCHOR: here -} -// ANCHOR_END: here diff --git a/listings/ch13-functional-features/listing-13-26/Cargo.lock b/listings/ch13-functional-features/listing-13-26/Cargo.lock deleted file mode 100755 index 88bf82d..0000000 --- a/listings/ch13-functional-features/listing-13-26/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "minigrep" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-26/Cargo.toml b/listings/ch13-functional-features/listing-13-26/Cargo.toml deleted file mode 100755 index 64c2a3f..0000000 --- a/listings/ch13-functional-features/listing-13-26/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "minigrep" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-26/poem.txt b/listings/ch13-functional-features/listing-13-26/poem.txt deleted file mode 100755 index 8707527..0000000 --- a/listings/ch13-functional-features/listing-13-26/poem.txt +++ /dev/null @@ -1,9 +0,0 @@ -I'm nobody! Who are you? -Are you nobody, too? -Then there's a pair of us - don't tell! -They'd banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! diff --git a/listings/ch13-functional-features/listing-13-26/src/lib.rs b/listings/ch13-functional-features/listing-13-26/src/lib.rs deleted file mode 100755 index 2cb0bea..0000000 --- a/listings/ch13-functional-features/listing-13-26/src/lib.rs +++ /dev/null @@ -1,107 +0,0 @@ -use std::env; -use std::error::Error; -use std::fs; - -pub struct Config { - pub query: String, - pub filename: String, - pub case_sensitive: bool, -} - -// ANCHOR: here -impl Config { - pub fn new(mut args: env::Args) -> Result { - // --snip-- - // ANCHOR_END: here - if args.len() < 3 { - return Err("not enough arguments"); - } - - let query = args[1].clone(); - let filename = args[2].clone(); - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { - query, - filename, - case_sensitive, - }) - } -} - -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - let results = if config.case_sensitive { - search(&config.query, &contents) - } else { - search_case_insensitive(&config.query, &contents) - }; - - for line in results { - println!("{}", line); - } - - Ok(()) -} - -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let mut results = Vec::new(); - - for line in contents.lines() { - if line.contains(query) { - results.push(line); - } - } - - results -} - -pub fn search_case_insensitive<'a>( - query: &str, - contents: &'a str, -) -> Vec<&'a str> { - let query = query.to_lowercase(); - let mut results = Vec::new(); - - for line in contents.lines() { - if line.to_lowercase().contains(&query) { - results.push(line); - } - } - - results -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn case_sensitive() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Duct tape."; - - assert_eq!(vec!["safe, fast, productive."], search(query, contents)); - } - - #[test] - fn case_insensitive() { - let query = "rUsT"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Trust me."; - - assert_eq!( - vec!["Rust:", "Trust me."], - search_case_insensitive(query, contents) - ); - } -} diff --git a/listings/ch13-functional-features/listing-13-26/src/main.rs b/listings/ch13-functional-features/listing-13-26/src/main.rs deleted file mode 100755 index 06aac30..0000000 --- a/listings/ch13-functional-features/listing-13-26/src/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env; -use std::process; - -use minigrep::Config; - -fn main() { - let config = Config::new(env::args()).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - if let Err(e) = minigrep::run(config) { - eprintln!("Application error: {}", e); - - process::exit(1); - } -} diff --git a/listings/ch13-functional-features/listing-13-27/Cargo.lock b/listings/ch13-functional-features/listing-13-27/Cargo.lock deleted file mode 100755 index 88bf82d..0000000 --- a/listings/ch13-functional-features/listing-13-27/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "minigrep" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-27/Cargo.toml b/listings/ch13-functional-features/listing-13-27/Cargo.toml deleted file mode 100755 index 64c2a3f..0000000 --- a/listings/ch13-functional-features/listing-13-27/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "minigrep" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-27/poem.txt b/listings/ch13-functional-features/listing-13-27/poem.txt deleted file mode 100755 index 8707527..0000000 --- a/listings/ch13-functional-features/listing-13-27/poem.txt +++ /dev/null @@ -1,9 +0,0 @@ -I'm nobody! Who are you? -Are you nobody, too? -Then there's a pair of us - don't tell! -They'd banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! diff --git a/listings/ch13-functional-features/listing-13-27/src/lib.rs b/listings/ch13-functional-features/listing-13-27/src/lib.rs deleted file mode 100755 index 7a33565..0000000 --- a/listings/ch13-functional-features/listing-13-27/src/lib.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::env; -use std::error::Error; -use std::fs; - -pub struct Config { - pub query: String, - pub filename: String, - pub case_sensitive: bool, -} - -// ANCHOR: here -impl Config { - pub fn new(mut args: env::Args) -> Result { - args.next(); - - let query = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a query string"), - }; - - let filename = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a file name"), - }; - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { - query, - filename, - case_sensitive, - }) - } -} -// ANCHOR_END: here - -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - let results = if config.case_sensitive { - search(&config.query, &contents) - } else { - search_case_insensitive(&config.query, &contents) - }; - - for line in results { - println!("{}", line); - } - - Ok(()) -} - -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let mut results = Vec::new(); - - for line in contents.lines() { - if line.contains(query) { - results.push(line); - } - } - - results -} - -pub fn search_case_insensitive<'a>( - query: &str, - contents: &'a str, -) -> Vec<&'a str> { - let query = query.to_lowercase(); - let mut results = Vec::new(); - - for line in contents.lines() { - if line.to_lowercase().contains(&query) { - results.push(line); - } - } - - results -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn case_sensitive() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Duct tape."; - - assert_eq!(vec!["safe, fast, productive."], search(query, contents)); - } - - #[test] - fn case_insensitive() { - let query = "rUsT"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Trust me."; - - assert_eq!( - vec!["Rust:", "Trust me."], - search_case_insensitive(query, contents) - ); - } -} diff --git a/listings/ch13-functional-features/listing-13-27/src/main.rs b/listings/ch13-functional-features/listing-13-27/src/main.rs deleted file mode 100755 index 06aac30..0000000 --- a/listings/ch13-functional-features/listing-13-27/src/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env; -use std::process; - -use minigrep::Config; - -fn main() { - let config = Config::new(env::args()).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - if let Err(e) = minigrep::run(config) { - eprintln!("Application error: {}", e); - - process::exit(1); - } -} diff --git a/listings/ch13-functional-features/listing-13-29/Cargo.lock b/listings/ch13-functional-features/listing-13-29/Cargo.lock deleted file mode 100755 index 88bf82d..0000000 --- a/listings/ch13-functional-features/listing-13-29/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "minigrep" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/listing-13-29/Cargo.toml b/listings/ch13-functional-features/listing-13-29/Cargo.toml deleted file mode 100755 index 64c2a3f..0000000 --- a/listings/ch13-functional-features/listing-13-29/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "minigrep" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/listing-13-29/poem.txt b/listings/ch13-functional-features/listing-13-29/poem.txt deleted file mode 100755 index 8707527..0000000 --- a/listings/ch13-functional-features/listing-13-29/poem.txt +++ /dev/null @@ -1,9 +0,0 @@ -I'm nobody! Who are you? -Are you nobody, too? -Then there's a pair of us - don't tell! -They'd banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! diff --git a/listings/ch13-functional-features/listing-13-29/src/lib.rs b/listings/ch13-functional-features/listing-13-29/src/lib.rs deleted file mode 100755 index bc8a77e..0000000 --- a/listings/ch13-functional-features/listing-13-29/src/lib.rs +++ /dev/null @@ -1,106 +0,0 @@ -use std::env; -use std::error::Error; -use std::fs; - -pub struct Config { - pub query: String, - pub filename: String, - pub case_sensitive: bool, -} - -impl Config { - pub fn new(mut args: std::env::Args) -> Result { - args.next(); - - let query = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a query string"), - }; - - let filename = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a file name"), - }; - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { - query, - filename, - case_sensitive, - }) - } -} - -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - let results = if config.case_sensitive { - search(&config.query, &contents) - } else { - search_case_insensitive(&config.query, &contents) - }; - - for line in results { - println!("{}", line); - } - - Ok(()) -} - -// ANCHOR: here -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - contents - .lines() - .filter(|line| line.contains(query)) - .collect() -} -// ANCHOR_END: here - -pub fn search_case_insensitive<'a>( - query: &str, - contents: &'a str, -) -> Vec<&'a str> { - let query = query.to_lowercase(); - let mut results = Vec::new(); - - for line in contents.lines() { - if line.to_lowercase().contains(&query) { - results.push(line); - } - } - - results -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn case_sensitive() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Duct tape."; - - assert_eq!(vec!["safe, fast, productive."], search(query, contents)); - } - - #[test] - fn case_insensitive() { - let query = "rUsT"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Trust me."; - - assert_eq!( - vec!["Rust:", "Trust me."], - search_case_insensitive(query, contents) - ); - } -} diff --git a/listings/ch13-functional-features/listing-13-29/src/main.rs b/listings/ch13-functional-features/listing-13-29/src/main.rs deleted file mode 100755 index 06aac30..0000000 --- a/listings/ch13-functional-features/listing-13-29/src/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env; -use std::process; - -use minigrep::Config; - -fn main() { - let config = Config::new(env::args()).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - if let Err(e) = minigrep::run(config) { - eprintln!("Application error: {}", e); - - process::exit(1); - } -} diff --git a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.lock b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.lock deleted file mode 100755 index e090432..0000000 --- a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "cacher" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.toml b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.toml deleted file mode 100755 index 6b81ef9..0000000 --- a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "cacher" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt deleted file mode 100755 index c9bda8c..0000000 --- a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt +++ /dev/null @@ -1,23 +0,0 @@ -$ cargo test - Compiling cacher v0.1.0 (file:///projects/cacher) - Finished test [unoptimized + debuginfo] target(s) in 0.72s - Running unittests (target/debug/deps/cacher-074d7c200c000afa) - -running 1 test -test tests::call_with_different_values ... FAILED - -failures: - ----- tests::call_with_different_values stdout ---- -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `1`, - right: `2`', src/lib.rs:43:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - tests::call_with_different_values - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - -error: test failed, to rerun pass '--lib' diff --git a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/src/lib.rs b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/src/lib.rs deleted file mode 100755 index e7d677d..0000000 --- a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/src/lib.rs +++ /dev/null @@ -1,47 +0,0 @@ -struct Cacher -where - T: Fn(u32) -> u32, -{ - calculation: T, - value: Option, -} - -impl Cacher -where - T: Fn(u32) -> u32, -{ - fn new(calculation: T) -> Cacher { - Cacher { - calculation, - value: None, - } - } - - fn value(&mut self, arg: u32) -> u32 { - match self.value { - Some(v) => v, - None => { - let v = (self.calculation)(arg); - self.value = Some(v); - v - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - // ANCHOR: here - #[test] - fn call_with_different_values() { - let mut c = Cacher::new(|a| a); - - let v1 = c.value(1); - let v2 = c.value(2); - - assert_eq!(v2, 2); - } - // ANCHOR_END: here -} diff --git a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.lock b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.lock deleted file mode 100755 index a96532a..0000000 --- a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "equal-to-x" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.toml b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.toml deleted file mode 100755 index ca73ff7..0000000 --- a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "equal-to-x" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt deleted file mode 100755 index 3cf9915..0000000 --- a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt +++ /dev/null @@ -1,12 +0,0 @@ -$ cargo run - Compiling equal-to-x v0.1.0 (file:///projects/equal-to-x) -error[E0434]: can't capture dynamic environment in a fn item - --> src/main.rs:5:14 - | -5 | z == x - | ^ - | - = help: use the `|| { ... }` closure form instead - -For more information about this error, try `rustc --explain E0434`. -error: could not compile `equal-to-x` due to previous error diff --git a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/src/main.rs b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/src/main.rs deleted file mode 100755 index 1b5d2b9..0000000 --- a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/src/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn main() { - let x = 4; - - fn equal_to_x(z: i32) -> bool { - z == x - } - - let y = 4; - - assert!(equal_to_x(y)); -} diff --git a/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.lock b/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.lock deleted file mode 100755 index a96532a..0000000 --- a/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "equal-to-x" -version = "0.1.0" - diff --git a/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.toml b/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.toml deleted file mode 100755 index ca73ff7..0000000 --- a/listings/ch13-functional-features/no-listing-03-move-closures/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "equal-to-x" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch13-functional-features/no-listing-03-move-closures/output.txt b/listings/ch13-functional-features/no-listing-03-move-closures/output.txt deleted file mode 100755 index ae1aa91..0000000 --- a/listings/ch13-functional-features/no-listing-03-move-closures/output.txt +++ /dev/null @@ -1,18 +0,0 @@ -$ cargo run - Compiling equal-to-x v0.1.0 (file:///projects/equal-to-x) -error[E0382]: borrow of moved value: `x` - --> src/main.rs:6:40 - | -2 | let x = vec![1, 2, 3]; - | - move occurs because `x` has type `Vec`, which does not implement the `Copy` trait -3 | -4 | let equal_to_x = move |z| z == x; - | -------- - variable moved due to use in closure - | | - | value moved into closure here -5 | -6 | println!("can't use x here: {:?}", x); - | ^ value borrowed here after move - -For more information about this error, try `rustc --explain E0382`. -error: could not compile `equal-to-x` due to previous error diff --git a/listings/ch13-functional-features/no-listing-03-move-closures/src/main.rs b/listings/ch13-functional-features/no-listing-03-move-closures/src/main.rs deleted file mode 100755 index 19d4776..0000000 --- a/listings/ch13-functional-features/no-listing-03-move-closures/src/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn main() { - let x = vec![1, 2, 3]; - - let equal_to_x = move |z| z == x; - - println!("can't use x here: {:?}", x); - - let y = vec![1, 2, 3]; - - assert!(equal_to_x(y)); -} diff --git a/listings/ch14-more-about-cargo/listing-14-01/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-01/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-01/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-01/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-02/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-02/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-02/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-02/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-03/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-03/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-04/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-04/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-04/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-04/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-04/src/main.rs b/listings/ch14-more-about-cargo/listing-14-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-05/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-05/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-05/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-06/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-06/src/main.rs b/listings/ch14-more-about-cargo/listing-14-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/Cargo.lock b/listings/ch14-more-about-cargo/listing-14-07/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-07/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/add_one/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-07/add/add_one/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-07/add/add_one/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/listing-14-07/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs b/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/Cargo.lock b/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/adder/src/main.rs b/listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/Cargo.lock b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add_one/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add_one/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add_one/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/adder/src/main.rs b/listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/Cargo.lock b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/add_one/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/add_one/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/add_one/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/adder/src/main.rs b/listings/ch14-more-about-cargo/no-listing-03-workspace-with-external-dependency/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/Cargo.lock b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/add_one/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/add_one/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/add_one/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/adder/src/main.rs b/listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/.gitignore b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/.gitignore old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.toml b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/rustfmt-ignore b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/.gitignore b/listings/ch14-more-about-cargo/output-only-02-add-one/add/.gitignore deleted file mode 100755 index fc0f08e..0000000 --- a/listings/ch14-more-about-cargo/output-only-02-add-one/add/.gitignore +++ /dev/null @@ -1 +0,0 @@ -add_one diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.lock b/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml b/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/output-only-02-add-one/add/add_one/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/listings/ch14-more-about-cargo/output-only-02-add-one/add/add_one/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/output-only-02-add-one/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/adder/src/main.rs b/listings/ch14-more-about-cargo/output-only-02-add-one/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/Cargo.lock b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/Cargo.toml b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/add_one/Cargo.toml b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/add_one/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/add_one/src/lib.rs b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/add_one/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/adder/Cargo.toml b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/adder/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch14-more-about-cargo/output-only-03-use-rand/add/adder/src/main.rs b/listings/ch14-more-about-cargo/output-only-03-use-rand/add/adder/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-01/Cargo.lock b/listings/ch15-smart-pointers/listing-15-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-01/Cargo.toml b/listings/ch15-smart-pointers/listing-15-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-01/src/main.rs b/listings/ch15-smart-pointers/listing-15-01/src/main.rs old mode 100755 new mode 100644 index 8da1d90..97f04f3 --- a/listings/ch15-smart-pointers/listing-15-01/src/main.rs +++ b/listings/ch15-smart-pointers/listing-15-01/src/main.rs @@ -1,4 +1,4 @@ fn main() { let b = Box::new(5); - println!("b = {}", b); + println!("b = {b}"); } diff --git a/listings/ch15-smart-pointers/listing-15-02/Cargo.lock b/listings/ch15-smart-pointers/listing-15-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-02/Cargo.toml b/listings/ch15-smart-pointers/listing-15-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-02/src/main.rs b/listings/ch15-smart-pointers/listing-15-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-03/Cargo.lock b/listings/ch15-smart-pointers/listing-15-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-03/Cargo.toml b/listings/ch15-smart-pointers/listing-15-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-03/output.txt b/listings/ch15-smart-pointers/listing-15-03/output.txt old mode 100755 new mode 100644 index d5522cd..2563fb6 --- a/listings/ch15-smart-pointers/listing-15-03/output.txt +++ b/listings/ch15-smart-pointers/listing-15-03/output.txt @@ -4,14 +4,25 @@ error[E0072]: recursive type `List` has infinite size --> src/main.rs:1:1 | 1 | enum List { - | ^^^^^^^^^ recursive type has infinite size + | ^^^^^^^^^ 2 | Cons(i32, List), | ---- recursive without indirection | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `List` representable +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | 2 | Cons(i32, Box), | ++++ + -For more information about this error, try `rustc --explain E0072`. -error: could not compile `cons-list` due to previous error +error[E0391]: cycle detected when computing when `List` needs drop + --> src/main.rs:1:1 + | +1 | enum List { + | ^^^^^^^^^ + | + = note: ...which immediately requires computing when `List` needs drop again + = note: cycle used when computing whether `List` needs drop + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +Some errors have detailed explanations: E0072, E0391. +For more information about an error, try `rustc --explain E0072`. +error: could not compile `cons-list` (bin "cons-list") due to 2 previous errors diff --git a/listings/ch15-smart-pointers/listing-15-03/src/main.rs b/listings/ch15-smart-pointers/listing-15-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-05/Cargo.lock b/listings/ch15-smart-pointers/listing-15-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-05/Cargo.toml b/listings/ch15-smart-pointers/listing-15-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-05/src/main.rs b/listings/ch15-smart-pointers/listing-15-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-06/Cargo.lock b/listings/ch15-smart-pointers/listing-15-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-06/Cargo.toml b/listings/ch15-smart-pointers/listing-15-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-06/src/main.rs b/listings/ch15-smart-pointers/listing-15-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-07/Cargo.lock b/listings/ch15-smart-pointers/listing-15-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-07/Cargo.toml b/listings/ch15-smart-pointers/listing-15-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-07/src/main.rs b/listings/ch15-smart-pointers/listing-15-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-08/Cargo.lock b/listings/ch15-smart-pointers/listing-15-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-08/Cargo.toml b/listings/ch15-smart-pointers/listing-15-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-08/src/main.rs b/listings/ch15-smart-pointers/listing-15-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-09/Cargo.lock b/listings/ch15-smart-pointers/listing-15-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-09/Cargo.toml b/listings/ch15-smart-pointers/listing-15-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-09/output.txt b/listings/ch15-smart-pointers/listing-15-09/output.txt old mode 100755 new mode 100644 index 75e5f1c..a295d26 --- a/listings/ch15-smart-pointers/listing-15-09/output.txt +++ b/listings/ch15-smart-pointers/listing-15-09/output.txt @@ -7,4 +7,4 @@ error[E0614]: type `MyBox<{integer}>` cannot be dereferenced | ^^ For more information about this error, try `rustc --explain E0614`. -error: could not compile `deref-example` due to previous error +error: could not compile `deref-example` (bin "deref-example") due to 1 previous error diff --git a/listings/ch15-smart-pointers/listing-15-09/src/main.rs b/listings/ch15-smart-pointers/listing-15-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-10/Cargo.lock b/listings/ch15-smart-pointers/listing-15-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-10/Cargo.toml b/listings/ch15-smart-pointers/listing-15-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-10/src/main.rs b/listings/ch15-smart-pointers/listing-15-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-11/Cargo.lock b/listings/ch15-smart-pointers/listing-15-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-11/Cargo.toml b/listings/ch15-smart-pointers/listing-15-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-11/src/main.rs b/listings/ch15-smart-pointers/listing-15-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-12/Cargo.lock b/listings/ch15-smart-pointers/listing-15-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-12/Cargo.toml b/listings/ch15-smart-pointers/listing-15-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-12/src/main.rs b/listings/ch15-smart-pointers/listing-15-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-13/Cargo.lock b/listings/ch15-smart-pointers/listing-15-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-13/Cargo.toml b/listings/ch15-smart-pointers/listing-15-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-13/src/main.rs b/listings/ch15-smart-pointers/listing-15-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-14/Cargo.lock b/listings/ch15-smart-pointers/listing-15-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-14/Cargo.toml b/listings/ch15-smart-pointers/listing-15-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-14/output.txt b/listings/ch15-smart-pointers/listing-15-14/output.txt old mode 100755 new mode 100644 index 4e79594..1393d44 --- a/listings/ch15-smart-pointers/listing-15-14/output.txt +++ b/listings/ch15-smart-pointers/listing-15-14/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling drop-example v0.1.0 (file:///projects/drop-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.60s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.60s Running `target/debug/drop-example` CustomSmartPointers created. Dropping CustomSmartPointer with data `other stuff`! diff --git a/listings/ch15-smart-pointers/listing-15-14/src/main.rs b/listings/ch15-smart-pointers/listing-15-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-15/Cargo.lock b/listings/ch15-smart-pointers/listing-15-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-15/Cargo.toml b/listings/ch15-smart-pointers/listing-15-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-15/output.txt b/listings/ch15-smart-pointers/listing-15-15/output.txt old mode 100755 new mode 100644 index a38c9cc..8a53b28 --- a/listings/ch15-smart-pointers/listing-15-15/output.txt +++ b/listings/ch15-smart-pointers/listing-15-15/output.txt @@ -4,10 +4,12 @@ error[E0040]: explicit use of destructor method --> src/main.rs:16:7 | 16 | c.drop(); - | --^^^^-- - | | | - | | explicit destructor calls not allowed - | help: consider using `drop` function: `drop(c)` + | ^^^^ explicit destructor calls not allowed + | +help: consider using `drop` function + | +16 | drop(c); + | +++++ ~ For more information about this error, try `rustc --explain E0040`. -error: could not compile `drop-example` due to previous error +error: could not compile `drop-example` (bin "drop-example") due to 1 previous error diff --git a/listings/ch15-smart-pointers/listing-15-15/src/main.rs b/listings/ch15-smart-pointers/listing-15-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-16/Cargo.lock b/listings/ch15-smart-pointers/listing-15-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-16/Cargo.toml b/listings/ch15-smart-pointers/listing-15-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-16/output.txt b/listings/ch15-smart-pointers/listing-15-16/output.txt old mode 100755 new mode 100644 index e960cd8..f032d84 --- a/listings/ch15-smart-pointers/listing-15-16/output.txt +++ b/listings/ch15-smart-pointers/listing-15-16/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling drop-example v0.1.0 (file:///projects/drop-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.73s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.73s Running `target/debug/drop-example` CustomSmartPointer created. Dropping CustomSmartPointer with data `some data`! diff --git a/listings/ch15-smart-pointers/listing-15-16/src/main.rs b/listings/ch15-smart-pointers/listing-15-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-17/Cargo.lock b/listings/ch15-smart-pointers/listing-15-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-17/Cargo.toml b/listings/ch15-smart-pointers/listing-15-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-17/output.txt b/listings/ch15-smart-pointers/listing-15-17/output.txt old mode 100755 new mode 100644 index ab314d8..757a65f --- a/listings/ch15-smart-pointers/listing-15-17/output.txt +++ b/listings/ch15-smart-pointers/listing-15-17/output.txt @@ -11,4 +11,4 @@ error[E0382]: use of moved value: `a` | ^ value used here after move For more information about this error, try `rustc --explain E0382`. -error: could not compile `cons-list` due to previous error +error: could not compile `cons-list` (bin "cons-list") due to 1 previous error diff --git a/listings/ch15-smart-pointers/listing-15-17/src/main.rs b/listings/ch15-smart-pointers/listing-15-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-18/Cargo.lock b/listings/ch15-smart-pointers/listing-15-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-18/Cargo.toml b/listings/ch15-smart-pointers/listing-15-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-18/src/main.rs b/listings/ch15-smart-pointers/listing-15-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-19/Cargo.lock b/listings/ch15-smart-pointers/listing-15-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-19/Cargo.toml b/listings/ch15-smart-pointers/listing-15-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-19/output.txt b/listings/ch15-smart-pointers/listing-15-19/output.txt old mode 100755 new mode 100644 index 6a8cc8e..252ccae --- a/listings/ch15-smart-pointers/listing-15-19/output.txt +++ b/listings/ch15-smart-pointers/listing-15-19/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling cons-list v0.1.0 (file:///projects/cons-list) - Finished dev [unoptimized + debuginfo] target(s) in 0.45s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.45s Running `target/debug/cons-list` count after creating a = 1 count after creating b = 2 diff --git a/listings/ch15-smart-pointers/listing-15-19/src/main.rs b/listings/ch15-smart-pointers/listing-15-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-20/Cargo.lock b/listings/ch15-smart-pointers/listing-15-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-20/Cargo.toml b/listings/ch15-smart-pointers/listing-15-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-20/src/lib.rs b/listings/ch15-smart-pointers/listing-15-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-21/Cargo.lock b/listings/ch15-smart-pointers/listing-15-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-21/Cargo.toml b/listings/ch15-smart-pointers/listing-15-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-21/output.txt b/listings/ch15-smart-pointers/listing-15-21/output.txt old mode 100755 new mode 100644 index 6b07b66..3f00da3 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -3,12 +3,13 @@ $ cargo test error[E0596]: cannot borrow `self.sent_messages` as mutable, as it is behind a `&` reference --> src/lib.rs:58:13 | -2 | fn send(&self, msg: &str); - | ----- help: consider changing that to be a mutable reference: `&mut self` -... 58 | self.sent_messages.push(String::from(message)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +2 | fn send(&mut self, msg: &str); + | ~~~~~~~~~ For more information about this error, try `rustc --explain E0596`. -error: could not compile `limit-tracker` due to previous error -warning: build failed, waiting for other jobs to finish... +error: could not compile `limit-tracker` (lib test) due to 1 previous error diff --git a/listings/ch15-smart-pointers/listing-15-21/src/lib.rs b/listings/ch15-smart-pointers/listing-15-21/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-22/Cargo.lock b/listings/ch15-smart-pointers/listing-15-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-22/Cargo.toml b/listings/ch15-smart-pointers/listing-15-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-22/src/lib.rs b/listings/ch15-smart-pointers/listing-15-22/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-23/Cargo.lock b/listings/ch15-smart-pointers/listing-15-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-23/Cargo.toml b/listings/ch15-smart-pointers/listing-15-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt old mode 100755 new mode 100644 index 3749c84..d3e5602 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -1,6 +1,6 @@ $ cargo test Compiling limit-tracker v0.1.0 (file:///projects/limit-tracker) - Finished test [unoptimized + debuginfo] target(s) in 0.91s + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.91s Running unittests src/lib.rs (target/debug/deps/limit_tracker-e599811fa246dbde) running 1 test @@ -9,7 +9,8 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', src/lib.rs:60:53 +thread 'tests::it_sends_an_over_75_percent_warning_message' panicked at src/lib.rs:60:53: +already borrowed: BorrowMutError note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch15-smart-pointers/listing-15-23/src/lib.rs b/listings/ch15-smart-pointers/listing-15-23/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-24/Cargo.lock b/listings/ch15-smart-pointers/listing-15-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-24/Cargo.toml b/listings/ch15-smart-pointers/listing-15-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-24/output.txt b/listings/ch15-smart-pointers/listing-15-24/output.txt old mode 100755 new mode 100644 index 21b3530..bbdc588 --- a/listings/ch15-smart-pointers/listing-15-24/output.txt +++ b/listings/ch15-smart-pointers/listing-15-24/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling cons-list v0.1.0 (file:///projects/cons-list) - Finished dev [unoptimized + debuginfo] target(s) in 0.63s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.63s Running `target/debug/cons-list` a after = Cons(RefCell { value: 15 }, Nil) b after = Cons(RefCell { value: 3 }, Cons(RefCell { value: 15 }, Nil)) diff --git a/listings/ch15-smart-pointers/listing-15-24/src/main.rs b/listings/ch15-smart-pointers/listing-15-24/src/main.rs old mode 100755 new mode 100644 index e225bd8..e3dda1a --- a/listings/ch15-smart-pointers/listing-15-24/src/main.rs +++ b/listings/ch15-smart-pointers/listing-15-24/src/main.rs @@ -18,7 +18,7 @@ fn main() { *value.borrow_mut() += 10; - println!("a after = {:?}", a); - println!("b after = {:?}", b); - println!("c after = {:?}", c); + println!("a after = {a:?}"); + println!("b after = {b:?}"); + println!("c after = {c:?}"); } diff --git a/listings/ch15-smart-pointers/listing-15-25/Cargo.lock b/listings/ch15-smart-pointers/listing-15-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-25/Cargo.toml b/listings/ch15-smart-pointers/listing-15-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-25/src/main.rs b/listings/ch15-smart-pointers/listing-15-25/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-26/Cargo.lock b/listings/ch15-smart-pointers/listing-15-26/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-26/Cargo.toml b/listings/ch15-smart-pointers/listing-15-26/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-26/output.txt b/listings/ch15-smart-pointers/listing-15-26/output.txt old mode 100755 new mode 100644 index 8b8eb40..b8e70e4 --- a/listings/ch15-smart-pointers/listing-15-26/output.txt +++ b/listings/ch15-smart-pointers/listing-15-26/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling cons-list v0.1.0 (file:///projects/cons-list) - Finished dev [unoptimized + debuginfo] target(s) in 0.53s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.53s Running `target/debug/cons-list` a initial rc count = 1 a next item = Some(RefCell { value: Nil }) diff --git a/listings/ch15-smart-pointers/listing-15-26/src/main.rs b/listings/ch15-smart-pointers/listing-15-26/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-27/Cargo.lock b/listings/ch15-smart-pointers/listing-15-27/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-27/Cargo.toml b/listings/ch15-smart-pointers/listing-15-27/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-27/src/main.rs b/listings/ch15-smart-pointers/listing-15-27/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-28/Cargo.lock b/listings/ch15-smart-pointers/listing-15-28/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-28/Cargo.toml b/listings/ch15-smart-pointers/listing-15-28/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-28/src/main.rs b/listings/ch15-smart-pointers/listing-15-28/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-29/Cargo.lock b/listings/ch15-smart-pointers/listing-15-29/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-29/Cargo.toml b/listings/ch15-smart-pointers/listing-15-29/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/listing-15-29/src/main.rs b/listings/ch15-smart-pointers/listing-15-29/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/Cargo.lock b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/Cargo.toml b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt old mode 100755 new mode 100644 index 8e84746..95b9b68 --- a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt +++ b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt @@ -3,10 +3,13 @@ $ cargo run error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> src/main.rs:3:13 | -2 | let x = 5; - | - help: consider changing this to be mutable: `mut x` 3 | let y = &mut x; | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +2 | let mut x = 5; + | +++ For more information about this error, try `rustc --explain E0596`. -error: could not compile `borrowing` due to previous error +error: could not compile `borrowing` (bin "borrowing") due to 1 previous error diff --git a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/src/main.rs b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/Cargo.lock b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/Cargo.toml b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt old mode 100755 new mode 100644 index a03cc34..d1eccd2 --- a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt +++ b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt @@ -7,17 +7,7 @@ error[E0277]: can't compare `{integer}` with `&{integer}` | ^^^^^^^^^^^^^^^^ no implementation for `{integer} == &{integer}` | = help: the trait `PartialEq<&{integer}>` is not implemented for `{integer}` - = help: the following other types implement trait `PartialEq`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. -error: could not compile `deref-example` due to previous error +error: could not compile `deref-example` (bin "deref-example") due to 1 previous error diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/src/main.rs b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-01/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-01/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-01/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-01/src/main.rs old mode 100755 new mode 100644 index 6305a98..ea10ba2 --- a/listings/ch16-fearless-concurrency/listing-16-01/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-01/src/main.rs @@ -4,13 +4,13 @@ use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { - println!("hi number {} from the spawned thread!", i); + println!("hi number {i} from the spawned thread!"); thread::sleep(Duration::from_millis(1)); } }); for i in 1..5 { - println!("hi number {} from the main thread!", i); + println!("hi number {i} from the main thread!"); thread::sleep(Duration::from_millis(1)); } } diff --git a/listings/ch16-fearless-concurrency/listing-16-02/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-02/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-02/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-02/src/main.rs old mode 100755 new mode 100644 index e37607f..33bf53f --- a/listings/ch16-fearless-concurrency/listing-16-02/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-02/src/main.rs @@ -4,13 +4,13 @@ use std::time::Duration; fn main() { let handle = thread::spawn(|| { for i in 1..10 { - println!("hi number {} from the spawned thread!", i); + println!("hi number {i} from the spawned thread!"); thread::sleep(Duration::from_millis(1)); } }); for i in 1..5 { - println!("hi number {} from the main thread!", i); + println!("hi number {i} from the main thread!"); thread::sleep(Duration::from_millis(1)); } diff --git a/listings/ch16-fearless-concurrency/listing-16-03/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-03/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-03/output.txt b/listings/ch16-fearless-concurrency/listing-16-03/output.txt old mode 100755 new mode 100644 index 321bf59..3de4d4d --- a/listings/ch16-fearless-concurrency/listing-16-03/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-03/output.txt @@ -5,15 +5,15 @@ error[E0373]: closure may outlive the current function, but it borrows `v`, whic | 6 | let handle = thread::spawn(|| { | ^^ may outlive borrowed value `v` -7 | println!("Here's a vector: {:?}", v); - | - `v` is borrowed here +7 | println!("Here's a vector: {v:?}"); + | - `v` is borrowed here | note: function requires argument type to outlive `'static` --> src/main.rs:6:18 | 6 | let handle = thread::spawn(|| { | __________________^ -7 | | println!("Here's a vector: {:?}", v); +7 | | println!("Here's a vector: {v:?}"); 8 | | }); | |______^ help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword @@ -22,4 +22,4 @@ help: to force the closure to take ownership of `v` (and any other referenced va | ++++ For more information about this error, try `rustc --explain E0373`. -error: could not compile `threads` due to previous error +error: could not compile `threads` (bin "threads") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs old mode 100755 new mode 100644 index defc876..b2231c5 --- a/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![1, 2, 3]; let handle = thread::spawn(|| { - println!("Here's a vector: {:?}", v); + println!("Here's a vector: {v:?}"); }); handle.join().unwrap(); diff --git a/listings/ch16-fearless-concurrency/listing-16-04/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-04/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-04/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-04/src/main.rs old mode 100755 new mode 100644 index 0bccc5f..f0a9058 --- a/listings/ch16-fearless-concurrency/listing-16-04/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-04/src/main.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![1, 2, 3]; let handle = thread::spawn(|| { - println!("Here's a vector: {:?}", v); + println!("Here's a vector: {v:?}"); }); drop(v); // oh no! diff --git a/listings/ch16-fearless-concurrency/listing-16-05/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-05/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs old mode 100755 new mode 100644 index a6547dc..76783e6 --- a/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![1, 2, 3]; let handle = thread::spawn(move || { - println!("Here's a vector: {:?}", v); + println!("Here's a vector: {v:?}"); }); handle.join().unwrap(); diff --git a/listings/ch16-fearless-concurrency/listing-16-06/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-06/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-06/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-07/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-07/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-07/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-08/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-08/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs old mode 100755 new mode 100644 index fbba916..e7ac452 --- a/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs @@ -10,5 +10,5 @@ fn main() { }); let received = rx.recv().unwrap(); - println!("Got: {}", received); + println!("Got: {received}"); } diff --git a/listings/ch16-fearless-concurrency/listing-16-09/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-09/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-09/output.txt b/listings/ch16-fearless-concurrency/listing-16-09/output.txt old mode 100755 new mode 100644 index db85185..ed4797f --- a/listings/ch16-fearless-concurrency/listing-16-09/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-09/output.txt @@ -1,16 +1,20 @@ $ cargo run Compiling message-passing v0.1.0 (file:///projects/message-passing) error[E0382]: borrow of moved value: `val` - --> src/main.rs:10:31 + --> src/main.rs:10:26 | 8 | let val = String::from("hi"); | --- move occurs because `val` has type `String`, which does not implement the `Copy` trait 9 | tx.send(val).unwrap(); | --- value moved here -10 | println!("val is {}", val); - | ^^^ value borrowed here after move +10 | println!("val is {val}"); + | ^^^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +9 | tx.send(val.clone()).unwrap(); + | ++++++++ For more information about this error, try `rustc --explain E0382`. -error: could not compile `message-passing` due to previous error +error: could not compile `message-passing` (bin "message-passing") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs old mode 100755 new mode 100644 index 98a8129..fe20d34 --- a/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs @@ -7,9 +7,9 @@ fn main() { thread::spawn(move || { let val = String::from("hi"); tx.send(val).unwrap(); - println!("val is {}", val); + println!("val is {val}"); }); let received = rx.recv().unwrap(); - println!("Got: {}", received); + println!("Got: {received}"); } diff --git a/listings/ch16-fearless-concurrency/listing-16-10/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-10/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-10/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-10/src/main.rs old mode 100755 new mode 100644 index 82b220d..c9702bd --- a/listings/ch16-fearless-concurrency/listing-16-10/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-10/src/main.rs @@ -20,6 +20,6 @@ fn main() { }); for received in rx { - println!("Got: {}", received); + println!("Got: {received}"); } } diff --git a/listings/ch16-fearless-concurrency/listing-16-11/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-11/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-11/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-11/src/main.rs old mode 100755 new mode 100644 index d92deab..174a5d1 --- a/listings/ch16-fearless-concurrency/listing-16-11/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-11/src/main.rs @@ -38,7 +38,7 @@ fn main() { }); for received in rx { - println!("Got: {}", received); + println!("Got: {received}"); } // --snip-- diff --git a/listings/ch16-fearless-concurrency/listing-16-12/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-12/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-12/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-12/src/main.rs old mode 100755 new mode 100644 index 0c0d676..99ba5b4 --- a/listings/ch16-fearless-concurrency/listing-16-12/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-12/src/main.rs @@ -8,5 +8,5 @@ fn main() { *num = 6; } - println!("m = {:?}", m); + println!("m = {m:?}"); } diff --git a/listings/ch16-fearless-concurrency/listing-16-13/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-13/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-13/output.txt b/listings/ch16-fearless-concurrency/listing-16-13/output.txt old mode 100755 new mode 100644 index ea69639..5405f76 --- a/listings/ch16-fearless-concurrency/listing-16-13/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-13/output.txt @@ -1,15 +1,16 @@ $ cargo run Compiling shared-state v0.1.0 (file:///projects/shared-state) -error[E0382]: use of moved value: `counter` - --> src/main.rs:9:36 +error[E0382]: borrow of moved value: `counter` + --> src/main.rs:21:29 | 5 | let counter = Mutex::new(0); | ------- move occurs because `counter` has type `Mutex`, which does not implement the `Copy` trait ... 9 | let handle = thread::spawn(move || { - | ^^^^^^^ value moved into closure here, in previous iteration of loop -10 | let mut num = counter.lock().unwrap(); - | ------- use occurs due to use in closure + | ------- value moved into closure here, in previous iteration of loop +... +21 | println!("Result: {}", *counter.lock().unwrap()); + | ^^^^^^^ value borrowed here after move For more information about this error, try `rustc --explain E0382`. -error: could not compile `shared-state` due to previous error +error: could not compile `shared-state` (bin "shared-state") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/listing-16-13/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-14/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-14/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-14/output.txt b/listings/ch16-fearless-concurrency/listing-16-14/output.txt old mode 100755 new mode 100644 index 0634b86..011e662 --- a/listings/ch16-fearless-concurrency/listing-16-14/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-14/output.txt @@ -6,7 +6,7 @@ error[E0277]: `Rc>` cannot be sent between threads safely 11 | let handle = thread::spawn(move || { | ------------- ^------ | | | - | ______________________|_____________within this `[closure@src/main.rs:11:36: 11:43]` + | ______________________|_____________within this `{closure@src/main.rs:11:36: 11:43}` | | | | | required by a bound introduced by this call 12 | | let mut num = counter.lock().unwrap(); @@ -15,13 +15,14 @@ error[E0277]: `Rc>` cannot be sent between threads safely 15 | | }); | |_________^ `Rc>` cannot be sent between threads safely | - = help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc>` + = help: within `{closure@src/main.rs:11:36: 11:43}`, the trait `Send` is not implemented for `Rc>`, which is required by `{closure@src/main.rs:11:36: 11:43}: Send` note: required because it's used within this closure --> src/main.rs:11:36 | 11 | let handle = thread::spawn(move || { | ^^^^^^^ note: required by a bound in `spawn` + --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:677:1 For more information about this error, try `rustc --explain E0277`. -error: could not compile `shared-state` due to previous error +error: could not compile `shared-state` (bin "shared-state") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/listing-16-14/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-15/Cargo.lock b/listings/ch16-fearless-concurrency/listing-16-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-15/Cargo.toml b/listings/ch16-fearless-concurrency/listing-16-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/listing-16-15/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/Cargo.lock b/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/Cargo.toml b/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/src/main.rs b/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/src/main.rs old mode 100755 new mode 100644 index 6205e57..7023a90 --- a/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/src/main.rs +++ b/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/src/main.rs @@ -4,7 +4,7 @@ use std::time::Duration; fn main() { let handle = thread::spawn(|| { for i in 1..10 { - println!("hi number {} from the spawned thread!", i); + println!("hi number {i} from the spawned thread!"); thread::sleep(Duration::from_millis(1)); } }); @@ -12,7 +12,7 @@ fn main() { handle.join().unwrap(); for i in 1..5 { - println!("hi number {} from the main thread!", i); + println!("hi number {i} from the main thread!"); thread::sleep(Duration::from_millis(1)); } } diff --git a/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/Cargo.lock b/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/Cargo.toml b/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/src/main.rs b/listings/ch16-fearless-concurrency/no-listing-02-no-loop-to-understand-error/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/output-only-01-move-drop/Cargo.lock b/listings/ch16-fearless-concurrency/output-only-01-move-drop/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/output-only-01-move-drop/Cargo.toml b/listings/ch16-fearless-concurrency/output-only-01-move-drop/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt b/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt old mode 100755 new mode 100644 index 301a9a4..929354c --- a/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt +++ b/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt @@ -8,11 +8,11 @@ error[E0382]: use of moved value: `v` 5 | 6 | let handle = thread::spawn(move || { | ------- value moved into closure here -7 | println!("Here's a vector: {:?}", v); - | - variable moved due to use in closure +7 | println!("Here's a vector: {v:?}"); + | - variable moved due to use in closure ... 10 | drop(v); // oh no! | ^ value used here after move For more information about this error, try `rustc --explain E0382`. -error: could not compile `threads` due to previous error +error: could not compile `threads` (bin "threads") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/output-only-01-move-drop/src/main.rs b/listings/ch16-fearless-concurrency/output-only-01-move-drop/src/main.rs old mode 100755 new mode 100644 index 70f659c..cc71cba --- a/listings/ch16-fearless-concurrency/output-only-01-move-drop/src/main.rs +++ b/listings/ch16-fearless-concurrency/output-only-01-move-drop/src/main.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![1, 2, 3]; let handle = thread::spawn(move || { - println!("Here's a vector: {:?}", v); + println!("Here's a vector: {v:?}"); }); drop(v); // oh no! diff --git a/listings/ch17-oop/listing-17-01/Cargo.lock b/listings/ch17-oop/listing-17-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-01/Cargo.toml b/listings/ch17-oop/listing-17-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-01/src/lib.rs b/listings/ch17-oop/listing-17-01/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-02/Cargo.lock b/listings/ch17-oop/listing-17-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-02/Cargo.toml b/listings/ch17-oop/listing-17-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-02/src/lib.rs b/listings/ch17-oop/listing-17-02/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-03/Cargo.lock b/listings/ch17-oop/listing-17-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-03/Cargo.toml b/listings/ch17-oop/listing-17-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-03/src/lib.rs b/listings/ch17-oop/listing-17-03/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-04/Cargo.lock b/listings/ch17-oop/listing-17-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-04/Cargo.toml b/listings/ch17-oop/listing-17-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-04/src/lib.rs b/listings/ch17-oop/listing-17-04/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-05/Cargo.lock b/listings/ch17-oop/listing-17-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-05/Cargo.toml b/listings/ch17-oop/listing-17-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-05/src/lib.rs b/listings/ch17-oop/listing-17-05/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-06/Cargo.lock b/listings/ch17-oop/listing-17-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-06/Cargo.toml b/listings/ch17-oop/listing-17-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-06/src/lib.rs b/listings/ch17-oop/listing-17-06/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-07/Cargo.lock b/listings/ch17-oop/listing-17-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-07/Cargo.toml b/listings/ch17-oop/listing-17-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-07/src/lib.rs b/listings/ch17-oop/listing-17-07/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-08/Cargo.lock b/listings/ch17-oop/listing-17-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-08/Cargo.toml b/listings/ch17-oop/listing-17-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-08/src/lib.rs b/listings/ch17-oop/listing-17-08/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-08/src/main.rs b/listings/ch17-oop/listing-17-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-09/Cargo.lock b/listings/ch17-oop/listing-17-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-09/Cargo.toml b/listings/ch17-oop/listing-17-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-09/src/lib.rs b/listings/ch17-oop/listing-17-09/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-09/src/main.rs b/listings/ch17-oop/listing-17-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-10/Cargo.lock b/listings/ch17-oop/listing-17-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-10/Cargo.toml b/listings/ch17-oop/listing-17-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-10/output.txt b/listings/ch17-oop/listing-17-10/output.txt old mode 100755 new mode 100644 index e0a455f..78d7c39 --- a/listings/ch17-oop/listing-17-10/output.txt +++ b/listings/ch17-oop/listing-17-10/output.txt @@ -7,7 +7,7 @@ error[E0277]: the trait bound `String: Draw` is not satisfied | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Draw` is not implemented for `String` | = help: the trait `Draw` is implemented for `Button` - = note: required for the cast from `String` to the object type `dyn Draw` + = note: required for the cast from `Box` to `Box` For more information about this error, try `rustc --explain E0277`. -error: could not compile `gui` due to previous error +error: could not compile `gui` (bin "gui") due to 1 previous error diff --git a/listings/ch17-oop/listing-17-10/src/lib.rs b/listings/ch17-oop/listing-17-10/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-10/src/main.rs b/listings/ch17-oop/listing-17-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-11/Cargo.lock b/listings/ch17-oop/listing-17-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-11/Cargo.toml b/listings/ch17-oop/listing-17-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-11/src/main.rs b/listings/ch17-oop/listing-17-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-12/Cargo.lock b/listings/ch17-oop/listing-17-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-12/Cargo.toml b/listings/ch17-oop/listing-17-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-12/src/lib.rs b/listings/ch17-oop/listing-17-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-12/src/main.rs b/listings/ch17-oop/listing-17-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-13/Cargo.lock b/listings/ch17-oop/listing-17-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-13/Cargo.toml b/listings/ch17-oop/listing-17-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-13/src/lib.rs b/listings/ch17-oop/listing-17-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-13/src/main.rs b/listings/ch17-oop/listing-17-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-14/Cargo.lock b/listings/ch17-oop/listing-17-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-14/Cargo.toml b/listings/ch17-oop/listing-17-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-14/src/lib.rs b/listings/ch17-oop/listing-17-14/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-14/src/main.rs b/listings/ch17-oop/listing-17-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-15/Cargo.lock b/listings/ch17-oop/listing-17-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-15/Cargo.toml b/listings/ch17-oop/listing-17-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-15/src/lib.rs b/listings/ch17-oop/listing-17-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-15/src/main.rs b/listings/ch17-oop/listing-17-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-16/Cargo.lock b/listings/ch17-oop/listing-17-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-16/Cargo.toml b/listings/ch17-oop/listing-17-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-16/src/lib.rs b/listings/ch17-oop/listing-17-16/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-16/src/main.rs b/listings/ch17-oop/listing-17-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-17/Cargo.lock b/listings/ch17-oop/listing-17-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-17/Cargo.toml b/listings/ch17-oop/listing-17-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-17/src/lib.rs b/listings/ch17-oop/listing-17-17/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-17/src/main.rs b/listings/ch17-oop/listing-17-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-18/Cargo.lock b/listings/ch17-oop/listing-17-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-18/Cargo.toml b/listings/ch17-oop/listing-17-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-18/src/lib.rs b/listings/ch17-oop/listing-17-18/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-18/src/main.rs b/listings/ch17-oop/listing-17-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-19/Cargo.lock b/listings/ch17-oop/listing-17-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-19/Cargo.toml b/listings/ch17-oop/listing-17-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-19/src/lib.rs b/listings/ch17-oop/listing-17-19/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-20/Cargo.lock b/listings/ch17-oop/listing-17-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-20/Cargo.toml b/listings/ch17-oop/listing-17-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-20/src/lib.rs b/listings/ch17-oop/listing-17-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-21/Cargo.lock b/listings/ch17-oop/listing-17-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-21/Cargo.toml b/listings/ch17-oop/listing-17-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-21/src/lib.rs b/listings/ch17-oop/listing-17-21/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch17-oop/listing-17-21/src/main.rs b/listings/ch17-oop/listing-17-21/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-01/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-01/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-02/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-02/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-02/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-02/src/main.rs old mode 100755 new mode 100644 index 5f75a4f..2479d84 --- a/listings/ch18-patterns-and-matching/listing-18-02/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-02/src/main.rs @@ -7,7 +7,7 @@ fn main() { stack.push(3); while let Some(top) = stack.pop() { - println!("{}", top); + println!("{top}"); } // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-03/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-03/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-03/output.txt b/listings/ch18-patterns-and-matching/listing-18-03/output.txt old mode 100755 new mode 100644 index 02fdecb..9add287 --- a/listings/ch18-patterns-and-matching/listing-18-03/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-03/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling patterns v0.1.0 (file:///projects/patterns) - Finished dev [unoptimized + debuginfo] target(s) in 0.52s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.52s Running `target/debug/patterns` a is at index 0 b is at index 1 diff --git a/listings/ch18-patterns-and-matching/listing-18-03/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-03/src/main.rs old mode 100755 new mode 100644 index eb922d6..218c180 --- a/listings/ch18-patterns-and-matching/listing-18-03/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-03/src/main.rs @@ -3,7 +3,7 @@ fn main() { let v = vec!['a', 'b', 'c']; for (index, value) in v.iter().enumerate() { - println!("{} is at index {}", value, index); + println!("{value} is at index {index}"); } // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-04/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-04/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-04/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-05/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-05/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-05/output.txt b/listings/ch18-patterns-and-matching/listing-18-05/output.txt old mode 100755 new mode 100644 index 57916a1..8002272 --- a/listings/ch18-patterns-and-matching/listing-18-05/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-05/output.txt @@ -12,4 +12,4 @@ error[E0308]: mismatched types found tuple `(_, _)` For more information about this error, try `rustc --explain E0308`. -error: could not compile `patterns` due to previous error +error: could not compile `patterns` (bin "patterns") due to 1 previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-05/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-06/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-06/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-06/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-07/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-07/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-07/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-07/src/main.rs old mode 100755 new mode 100644 index 4eccb80..7006942 --- a/listings/ch18-patterns-and-matching/listing-18-07/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-07/src/main.rs @@ -1,5 +1,5 @@ fn print_coordinates(&(x, y): &(i32, i32)) { - println!("Current location: ({}, {})", x, y); + println!("Current location: ({x}, {y})"); } fn main() { diff --git a/listings/ch18-patterns-and-matching/listing-18-08/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-08/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-08/output.txt b/listings/ch18-patterns-and-matching/listing-18-08/output.txt old mode 100755 new mode 100644 index 0fd5373..6ce3dfc --- a/listings/ch18-patterns-and-matching/listing-18-08/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-08/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling patterns v0.1.0 (file:///projects/patterns) -error[E0005]: refutable pattern in local binding: `None` not covered +error[E0005]: refutable pattern in local binding --> src/main.rs:3:9 | 3 | let Some(x) = some_option_value; @@ -8,12 +8,11 @@ error[E0005]: refutable pattern in local binding: `None` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Option` defined here = note: the matched value is of type `Option` -help: you might want to use `if let` to ignore the variant that isn't matched +help: you might want to use `let else` to handle the variant that isn't matched | -3 | let x = if let Some(x) = some_option_value { x } else { todo!() }; - | ++++++++++ ++++++++++++++++++++++ +3 | let Some(x) = some_option_value else { todo!() }; + | ++++++++++++++++ For more information about this error, try `rustc --explain E0005`. -error: could not compile `patterns` due to previous error +error: could not compile `patterns` (bin "patterns") due to 1 previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-08/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-09/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-09/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-09/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-09/src/main.rs old mode 100755 new mode 100644 index d6274fc..e378c37 --- a/listings/ch18-patterns-and-matching/listing-18-09/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-09/src/main.rs @@ -2,7 +2,7 @@ fn main() { let some_option_value: Option = None; // ANCHOR: here if let Some(x) = some_option_value { - println!("{}", x); + println!("{x}"); } // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-10/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-10/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-10/output.txt b/listings/ch18-patterns-and-matching/listing-18-10/output.txt old mode 100755 new mode 100644 index 702d10a..97bc014 --- a/listings/ch18-patterns-and-matching/listing-18-10/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-10/output.txt @@ -6,11 +6,11 @@ warning: irrefutable `if let` pattern 2 | if let x = 5 { | ^^^^^^^^^ | - = note: `#[warn(irrefutable_let_patterns)]` on by default = note: this pattern will always match, so the `if let` is useless = help: consider replacing the `if let` with a `let` + = note: `#[warn(irrefutable_let_patterns)]` on by default warning: `patterns` (bin "patterns") generated 1 warning - Finished dev [unoptimized + debuginfo] target(s) in 0.39s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s Running `target/debug/patterns` 5 diff --git a/listings/ch18-patterns-and-matching/listing-18-10/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-10/src/main.rs old mode 100755 new mode 100644 index cb81772..2073948 --- a/listings/ch18-patterns-and-matching/listing-18-10/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-10/src/main.rs @@ -1,7 +1,7 @@ fn main() { // ANCHOR: here if let x = 5 { - println!("{}", x); + println!("{x}"); }; // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-11/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-11/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-11/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-11/src/main.rs old mode 100755 new mode 100644 index db942b7..0552128 --- a/listings/ch18-patterns-and-matching/listing-18-11/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-11/src/main.rs @@ -6,9 +6,9 @@ fn main() { match x { Some(50) => println!("Got 50"), Some(y) => println!("Matched, y = {y}"), - _ => println!("Default case, x = {:?}", x), + _ => println!("Default case, x = {x:?}"), } - println!("at the end: x = {:?}, y = {y}", x); + println!("at the end: x = {x:?}, y = {y}"); // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-12/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-12/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-12/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-13/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-13/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-13/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-14/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-14/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-14/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-15/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-15/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-15/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-15/src/main.rs old mode 100755 new mode 100644 index a3138b2..9407cc1 --- a/listings/ch18-patterns-and-matching/listing-18-15/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-15/src/main.rs @@ -19,7 +19,7 @@ fn main() { println!("Text message: {text}"); } Message::ChangeColor(r, g, b) => { - println!("Change the color to red {r}, green {g}, and blue {b}",) + println!("Change the color to red {r}, green {g}, and blue {b}") } } } diff --git a/listings/ch18-patterns-and-matching/listing-18-16/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-16/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-16/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-17/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-17/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-17/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-17/src/main.rs old mode 100755 new mode 100644 index cf1fbe0..7053860 --- a/listings/ch18-patterns-and-matching/listing-18-17/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-17/src/main.rs @@ -1,5 +1,5 @@ fn foo(_: i32, y: i32) { - println!("This code only uses the y parameter: {}", y); + println!("This code only uses the y parameter: {y}"); } fn main() { diff --git a/listings/ch18-patterns-and-matching/listing-18-18/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-18/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-18/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-18/src/main.rs old mode 100755 new mode 100644 index b776c64..2b88776 --- a/listings/ch18-patterns-and-matching/listing-18-18/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-18/src/main.rs @@ -12,6 +12,6 @@ fn main() { } } - println!("setting is {:?}", setting_value); + println!("setting is {setting_value:?}"); // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-19/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-19/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-19/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-20/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-20/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-20/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-21/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-21/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-21/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-21/src/main.rs old mode 100755 new mode 100644 index 9806105..320db62 --- a/listings/ch18-patterns-and-matching/listing-18-21/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-21/src/main.rs @@ -6,6 +6,6 @@ fn main() { println!("found a string"); } - println!("{:?}", s); + println!("{s:?}"); // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-22/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-22/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-22/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-22/src/main.rs old mode 100755 new mode 100644 index e2faa34..9df1492 --- a/listings/ch18-patterns-and-matching/listing-18-22/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-22/src/main.rs @@ -6,6 +6,6 @@ fn main() { println!("found a string"); } - println!("{:?}", s); + println!("{s:?}"); // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-23/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-23/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs old mode 100755 new mode 100644 index 7a9d9bb..491d6c5 --- a/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs @@ -9,7 +9,7 @@ fn main() { let origin = Point { x: 0, y: 0, z: 0 }; match origin { - Point { x, .. } => println!("x is {}", x), + Point { x, .. } => println!("x is {x}"), } // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/listing-18-24/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-24/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-24/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-24/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-25/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-25/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-25/output.txt b/listings/ch18-patterns-and-matching/listing-18-25/output.txt old mode 100755 new mode 100644 index 7e0357e..bd5e0f9 --- a/listings/ch18-patterns-and-matching/listing-18-25/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-25/output.txt @@ -8,4 +8,4 @@ error: `..` can only be used once per tuple pattern | | | previously used here -error: could not compile `patterns` due to previous error +error: could not compile `patterns` (bin "patterns") due to 1 previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-25/rustfmt-ignore b/listings/ch18-patterns-and-matching/listing-18-25/rustfmt-ignore old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-25/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-25/src/main.rs old mode 100755 new mode 100644 index b90884e..6c3b24b --- a/listings/ch18-patterns-and-matching/listing-18-25/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-25/src/main.rs @@ -3,7 +3,7 @@ fn main() { match numbers { (.., second, ..) => { - println!("Some numbers: {}", second) + println!("Some numbers: {second}") }, } } diff --git a/listings/ch18-patterns-and-matching/listing-18-26/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-26/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-26/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-26/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs old mode 100755 new mode 100644 index 41fce97..2566169 --- a/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs @@ -3,8 +3,8 @@ fn main() { let num = Some(4); match num { - Some(x) if x % 2 == 0 => println!("The number {} is even", x), - Some(x) => println!("The number {} is odd", x), + Some(x) if x % 2 == 0 => println!("The number {x} is even"), + Some(x) => println!("The number {x} is odd"), None => (), } // ANCHOR_END: here diff --git a/listings/ch18-patterns-and-matching/listing-18-27/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-27/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-27/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-27/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs old mode 100755 new mode 100644 index 8386a0a..06fd949 --- a/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs @@ -5,8 +5,8 @@ fn main() { match x { Some(50) => println!("Got 50"), Some(n) if n == y => println!("Matched, n = {n}"), - _ => println!("Default case, x = {:?}", x), + _ => println!("Default case, x = {x:?}"), } - println!("at the end: x = {:?}, y = {y}", x); + println!("at the end: x = {x:?}, y = {y}"); } diff --git a/listings/ch18-patterns-and-matching/listing-18-28/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-28/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-28/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-28/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-28/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-28/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-29/Cargo.lock b/listings/ch18-patterns-and-matching/listing-18-29/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-29/Cargo.toml b/listings/ch18-patterns-and-matching/listing-18-29/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/listing-18-29/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-29/src/main.rs old mode 100755 new mode 100644 index 3514deb..e36fda8 --- a/listings/ch18-patterns-and-matching/listing-18-29/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-29/src/main.rs @@ -9,11 +9,11 @@ fn main() { match msg { Message::Hello { id: id_variable @ 3..=7, - } => println!("Found an id in range: {}", id_variable), + } => println!("Found an id in range: {id_variable}"), Message::Hello { id: 10..=12 } => { println!("Found an id in another range") } - Message::Hello { id } => println!("Found some other id: {}", id), + Message::Hello { id } => println!("Found some other id: {id}"), } // ANCHOR_END: here } diff --git a/listings/ch18-patterns-and-matching/no-listing-01-literals/Cargo.lock b/listings/ch18-patterns-and-matching/no-listing-01-literals/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-01-literals/Cargo.toml b/listings/ch18-patterns-and-matching/no-listing-01-literals/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-01-literals/src/main.rs b/listings/ch18-patterns-and-matching/no-listing-01-literals/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/Cargo.lock b/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/Cargo.toml b/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/src/main.rs b/listings/ch18-patterns-and-matching/no-listing-02-multiple-patterns/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-03-ranges/Cargo.lock b/listings/ch18-patterns-and-matching/no-listing-03-ranges/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-03-ranges/Cargo.toml b/listings/ch18-patterns-and-matching/no-listing-03-ranges/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-03-ranges/src/main.rs b/listings/ch18-patterns-and-matching/no-listing-03-ranges/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/Cargo.lock b/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/Cargo.toml b/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/src/main.rs b/listings/ch18-patterns-and-matching/no-listing-04-ranges-of-char/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/Cargo.lock b/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/Cargo.toml b/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/src/main.rs b/listings/ch18-patterns-and-matching/no-listing-05-destructuring-structs-and-tuples/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.lock b/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.lock deleted file mode 100755 index 58b70c5..0000000 --- a/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "counter" -version = "0.1.0" - diff --git a/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.toml b/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.toml deleted file mode 100755 index 9e103f3..0000000 --- a/listings/ch19-advanced-features/listing-13-21-reproduced/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "counter" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs b/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs deleted file mode 100755 index 04c7f38..0000000 --- a/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct Counter { - count: u32, -} - -impl Counter { - fn new() -> Counter { - Counter { count: 0 } - } -} - -// ANCHOR: ch19 -impl Iterator for Counter { - type Item = u32; - - fn next(&mut self) -> Option { - // --snip-- - // ANCHOR_END: ch19 - if self.count < 5 { - self.count += 1; - Some(self.count) - } else { - None - } - } -} diff --git a/listings/ch19-advanced-features/listing-19-01/Cargo.lock b/listings/ch19-advanced-features/listing-19-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-01/Cargo.toml b/listings/ch19-advanced-features/listing-19-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-01/src/main.rs b/listings/ch19-advanced-features/listing-19-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-02/Cargo.lock b/listings/ch19-advanced-features/listing-19-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-02/Cargo.toml b/listings/ch19-advanced-features/listing-19-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-02/src/main.rs b/listings/ch19-advanced-features/listing-19-02/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-03/Cargo.lock b/listings/ch19-advanced-features/listing-19-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-03/Cargo.toml b/listings/ch19-advanced-features/listing-19-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-03/src/main.rs b/listings/ch19-advanced-features/listing-19-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-04/Cargo.lock b/listings/ch19-advanced-features/listing-19-04/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-04/Cargo.toml b/listings/ch19-advanced-features/listing-19-04/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-04/src/main.rs b/listings/ch19-advanced-features/listing-19-04/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-05/Cargo.lock b/listings/ch19-advanced-features/listing-19-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-05/Cargo.toml b/listings/ch19-advanced-features/listing-19-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-05/output.txt b/listings/ch19-advanced-features/listing-19-05/output.txt old mode 100755 new mode 100644 index f4b7582..44bcc09 --- a/listings/ch19-advanced-features/listing-19-05/output.txt +++ b/listings/ch19-advanced-features/listing-19-05/output.txt @@ -14,4 +14,4 @@ error[E0499]: cannot borrow `*values` as mutable more than once at a time | returning this value requires that `*values` is borrowed for `'1` For more information about this error, try `rustc --explain E0499`. -error: could not compile `unsafe-example` due to previous error +error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error diff --git a/listings/ch19-advanced-features/listing-19-05/src/main.rs b/listings/ch19-advanced-features/listing-19-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-06/Cargo.lock b/listings/ch19-advanced-features/listing-19-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-06/Cargo.toml b/listings/ch19-advanced-features/listing-19-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-06/src/main.rs b/listings/ch19-advanced-features/listing-19-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-07/Cargo.lock b/listings/ch19-advanced-features/listing-19-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-07/Cargo.toml b/listings/ch19-advanced-features/listing-19-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-07/src/main.rs b/listings/ch19-advanced-features/listing-19-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-08/Cargo.lock b/listings/ch19-advanced-features/listing-19-08/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-08/Cargo.toml b/listings/ch19-advanced-features/listing-19-08/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-08/src/main.rs b/listings/ch19-advanced-features/listing-19-08/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-09/Cargo.lock b/listings/ch19-advanced-features/listing-19-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-09/Cargo.toml b/listings/ch19-advanced-features/listing-19-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-09/src/main.rs b/listings/ch19-advanced-features/listing-19-09/src/main.rs old mode 100755 new mode 100644 index 82a4b42..fda5179 --- a/listings/ch19-advanced-features/listing-19-09/src/main.rs +++ b/listings/ch19-advanced-features/listing-19-09/src/main.rs @@ -1,5 +1,5 @@ static HELLO_WORLD: &str = "Hello, world!"; fn main() { - println!("name is: {}", HELLO_WORLD); + println!("name is: {HELLO_WORLD}"); } diff --git a/listings/ch19-advanced-features/listing-19-10/Cargo.lock b/listings/ch19-advanced-features/listing-19-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-10/Cargo.toml b/listings/ch19-advanced-features/listing-19-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-10/src/main.rs b/listings/ch19-advanced-features/listing-19-10/src/main.rs old mode 100755 new mode 100644 index e8dab68..b5559fd --- a/listings/ch19-advanced-features/listing-19-10/src/main.rs +++ b/listings/ch19-advanced-features/listing-19-10/src/main.rs @@ -10,6 +10,6 @@ fn main() { add_to_count(3); unsafe { - println!("COUNTER: {}", COUNTER); + println!("COUNTER: {COUNTER}"); } } diff --git a/listings/ch19-advanced-features/listing-19-11/Cargo.lock b/listings/ch19-advanced-features/listing-19-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-11/Cargo.toml b/listings/ch19-advanced-features/listing-19-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-11/src/main.rs b/listings/ch19-advanced-features/listing-19-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-12/Cargo.lock b/listings/ch19-advanced-features/listing-19-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-12/Cargo.toml b/listings/ch19-advanced-features/listing-19-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-12/src/lib.rs b/listings/ch19-advanced-features/listing-19-12/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-13/Cargo.lock b/listings/ch19-advanced-features/listing-19-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-13/Cargo.toml b/listings/ch19-advanced-features/listing-19-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-13/src/lib.rs b/listings/ch19-advanced-features/listing-19-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-14/Cargo.lock b/listings/ch19-advanced-features/listing-19-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-14/Cargo.toml b/listings/ch19-advanced-features/listing-19-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-14/src/main.rs b/listings/ch19-advanced-features/listing-19-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-15/Cargo.lock b/listings/ch19-advanced-features/listing-19-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-15/Cargo.toml b/listings/ch19-advanced-features/listing-19-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-15/src/lib.rs b/listings/ch19-advanced-features/listing-19-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-16/Cargo.lock b/listings/ch19-advanced-features/listing-19-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-16/Cargo.toml b/listings/ch19-advanced-features/listing-19-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-16/src/main.rs b/listings/ch19-advanced-features/listing-19-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-17/Cargo.lock b/listings/ch19-advanced-features/listing-19-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-17/Cargo.toml b/listings/ch19-advanced-features/listing-19-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-17/src/main.rs b/listings/ch19-advanced-features/listing-19-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-18/Cargo.lock b/listings/ch19-advanced-features/listing-19-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-18/Cargo.toml b/listings/ch19-advanced-features/listing-19-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-18/output.txt b/listings/ch19-advanced-features/listing-19-18/output.txt old mode 100755 new mode 100644 index 2e9da17..d7e315b --- a/listings/ch19-advanced-features/listing-19-18/output.txt +++ b/listings/ch19-advanced-features/listing-19-18/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling traits-example v0.1.0 (file:///projects/traits-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.46s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.46s Running `target/debug/traits-example` This is your captain speaking. Up! diff --git a/listings/ch19-advanced-features/listing-19-18/src/main.rs b/listings/ch19-advanced-features/listing-19-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-19/Cargo.lock b/listings/ch19-advanced-features/listing-19-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-19/Cargo.toml b/listings/ch19-advanced-features/listing-19-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-19/output.txt b/listings/ch19-advanced-features/listing-19-19/output.txt old mode 100755 new mode 100644 index 087e802..b6e283f --- a/listings/ch19-advanced-features/listing-19-19/output.txt +++ b/listings/ch19-advanced-features/listing-19-19/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling traits-example v0.1.0 (file:///projects/traits-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.54s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.54s Running `target/debug/traits-example` A baby dog is called a Spot diff --git a/listings/ch19-advanced-features/listing-19-19/src/main.rs b/listings/ch19-advanced-features/listing-19-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-20/Cargo.lock b/listings/ch19-advanced-features/listing-19-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-20/Cargo.toml b/listings/ch19-advanced-features/listing-19-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-20/output.txt b/listings/ch19-advanced-features/listing-19-20/output.txt old mode 100755 new mode 100644 index a3b281e..0e78ae2 --- a/listings/ch19-advanced-features/listing-19-20/output.txt +++ b/listings/ch19-advanced-features/listing-19-20/output.txt @@ -7,12 +7,12 @@ error[E0790]: cannot call associated function on trait without specifying the co | ------------------------- `Animal::baby_name` defined here ... 20 | println!("A baby dog is called a {}", Animal::baby_name()); - | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use the fully-qualified path to the only available implementation | -20 | println!("A baby dog is called a {}", <::Dog as Animal>::baby_name()); - | +++++++++ + +20 | println!("A baby dog is called a {}", ::baby_name()); + | +++++++ + For more information about this error, try `rustc --explain E0790`. -error: could not compile `traits-example` due to previous error +error: could not compile `traits-example` (bin "traits-example") due to 1 previous error diff --git a/listings/ch19-advanced-features/listing-19-20/src/main.rs b/listings/ch19-advanced-features/listing-19-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-21/Cargo.lock b/listings/ch19-advanced-features/listing-19-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-21/Cargo.toml b/listings/ch19-advanced-features/listing-19-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-21/output.txt b/listings/ch19-advanced-features/listing-19-21/output.txt old mode 100755 new mode 100644 index 4d1ee5a..f59d0bc --- a/listings/ch19-advanced-features/listing-19-21/output.txt +++ b/listings/ch19-advanced-features/listing-19-21/output.txt @@ -1,5 +1,5 @@ $ cargo run Compiling traits-example v0.1.0 (file:///projects/traits-example) - Finished dev [unoptimized + debuginfo] target(s) in 0.48s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `target/debug/traits-example` A baby dog is called a puppy diff --git a/listings/ch19-advanced-features/listing-19-21/src/main.rs b/listings/ch19-advanced-features/listing-19-21/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-22/Cargo.lock b/listings/ch19-advanced-features/listing-19-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-22/Cargo.toml b/listings/ch19-advanced-features/listing-19-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-22/src/main.rs b/listings/ch19-advanced-features/listing-19-22/src/main.rs old mode 100755 new mode 100644 index febe58b..7069fef --- a/listings/ch19-advanced-features/listing-19-22/src/main.rs +++ b/listings/ch19-advanced-features/listing-19-22/src/main.rs @@ -7,7 +7,7 @@ trait OutlinePrint: fmt::Display { let len = output.len(); println!("{}", "*".repeat(len + 4)); println!("*{}*", " ".repeat(len + 2)); - println!("* {} *", output); + println!("* {output} *"); println!("*{}*", " ".repeat(len + 2)); println!("{}", "*".repeat(len + 4)); } diff --git a/listings/ch19-advanced-features/listing-19-23/Cargo.lock b/listings/ch19-advanced-features/listing-19-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-23/Cargo.toml b/listings/ch19-advanced-features/listing-19-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-23/src/main.rs b/listings/ch19-advanced-features/listing-19-23/src/main.rs old mode 100755 new mode 100644 index eae46c9..f8c8366 --- a/listings/ch19-advanced-features/listing-19-23/src/main.rs +++ b/listings/ch19-advanced-features/listing-19-23/src/main.rs @@ -10,5 +10,5 @@ impl fmt::Display for Wrapper { fn main() { let w = Wrapper(vec![String::from("hello"), String::from("world")]); - println!("w = {}", w); + println!("w = {w}"); } diff --git a/listings/ch19-advanced-features/listing-19-24/Cargo.lock b/listings/ch19-advanced-features/listing-19-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-24/Cargo.toml b/listings/ch19-advanced-features/listing-19-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-24/src/main.rs b/listings/ch19-advanced-features/listing-19-24/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-25/Cargo.lock b/listings/ch19-advanced-features/listing-19-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-25/Cargo.toml b/listings/ch19-advanced-features/listing-19-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-25/src/main.rs b/listings/ch19-advanced-features/listing-19-25/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-27/Cargo.lock b/listings/ch19-advanced-features/listing-19-27/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-27/Cargo.toml b/listings/ch19-advanced-features/listing-19-27/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-27/src/main.rs b/listings/ch19-advanced-features/listing-19-27/src/main.rs old mode 100755 new mode 100644 index 91b2cf0..312df24 --- a/listings/ch19-advanced-features/listing-19-27/src/main.rs +++ b/listings/ch19-advanced-features/listing-19-27/src/main.rs @@ -9,5 +9,5 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { fn main() { let answer = do_twice(add_one, 5); - println!("The answer is: {}", answer); + println!("The answer is: {answer}"); } diff --git a/listings/ch19-advanced-features/listing-19-28/Cargo.lock b/listings/ch19-advanced-features/listing-19-28/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-28/Cargo.toml b/listings/ch19-advanced-features/listing-19-28/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-28/src/lib.rs b/listings/ch19-advanced-features/listing-19-28/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-30/Cargo.lock b/listings/ch19-advanced-features/listing-19-30/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-30/Cargo.toml b/listings/ch19-advanced-features/listing-19-30/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-30/src/main.rs b/listings/ch19-advanced-features/listing-19-30/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/Cargo.lock b/listings/ch19-advanced-features/listing-19-31/hello_macro/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/Cargo.toml b/listings/ch19-advanced-features/listing-19-31/hello_macro/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.lock b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.lock old mode 100755 new mode 100644 index 9a38c8a..6be987b --- a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.lock +++ b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.lock @@ -1,46 +1,46 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "hello_macro_derive" version = "0.1.0" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "syn" -version = "1.0.14" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.toml b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.toml old mode 100755 new mode 100644 index aa076ac..ed9e917 --- a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.toml +++ b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" proc-macro = true [dependencies] -syn = "1.0" +syn = "2.0" quote = "1.0" diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/src/lib.rs b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/src/lib.rs old mode 100755 new mode 100644 index 11643a8..839ec83 --- a/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/src/lib.rs +++ b/listings/ch19-advanced-features/listing-19-31/hello_macro/hello_macro_derive/src/lib.rs @@ -1,6 +1,5 @@ use proc_macro::TokenStream; use quote::quote; -use syn; #[proc_macro_derive(HelloMacro)] pub fn hello_macro_derive(input: TokenStream) -> TokenStream { diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/src/lib.rs b/listings/ch19-advanced-features/listing-19-31/hello_macro/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-31/hello_macro/src/main.rs b/listings/ch19-advanced-features/listing-19-31/hello_macro/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/Cargo.lock b/listings/ch19-advanced-features/listing-19-33/hello_macro/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/Cargo.toml b/listings/ch19-advanced-features/listing-19-33/hello_macro/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.lock b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.lock old mode 100755 new mode 100644 index 9a38c8a..6be987b --- a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.lock +++ b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.lock @@ -1,46 +1,46 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "hello_macro_derive" version = "0.1.0" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "syn" -version = "1.0.14" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.toml b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.toml old mode 100755 new mode 100644 index aa076ac..ed9e917 --- a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.toml +++ b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" proc-macro = true [dependencies] -syn = "1.0" +syn = "2.0" quote = "1.0" diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/src/lib.rs b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/src/lib.rs old mode 100755 new mode 100644 index dac6c98..ba1215f --- a/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/src/lib.rs +++ b/listings/ch19-advanced-features/listing-19-33/hello_macro/hello_macro_derive/src/lib.rs @@ -1,6 +1,5 @@ use proc_macro::TokenStream; use quote::quote; -use syn; #[proc_macro_derive(HelloMacro)] pub fn hello_macro_derive(input: TokenStream) -> TokenStream { diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/src/lib.rs b/listings/ch19-advanced-features/listing-19-33/hello_macro/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/listing-19-33/hello_macro/src/main.rs b/listings/ch19-advanced-features/listing-19-33/hello_macro/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-01-unsafe-fn/Cargo.lock b/listings/ch19-advanced-features/no-listing-01-unsafe-fn/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-01-unsafe-fn/Cargo.toml b/listings/ch19-advanced-features/no-listing-01-unsafe-fn/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-01-unsafe-fn/src/main.rs b/listings/ch19-advanced-features/no-listing-01-unsafe-fn/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/Cargo.lock b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/Cargo.toml b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt old mode 100755 new mode 100644 index 0991f10..41af686 --- a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt +++ b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt @@ -1,10 +1,10 @@ $ cargo run Compiling traits-example v0.1.0 (file:///projects/traits-example) error[E0277]: `Point` doesn't implement `std::fmt::Display` - --> src/main.rs:20:6 + --> src/main.rs:20:23 | 20 | impl OutlinePrint for Point {} - | ^^^^^^^^^^^^ `Point` cannot be formatted with the default formatter + | ^^^^^ `Point` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `Point` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -14,5 +14,21 @@ note: required by a bound in `OutlinePrint` 3 | trait OutlinePrint: fmt::Display { | ^^^^^^^^^^^^ required by this bound in `OutlinePrint` +error[E0277]: `Point` doesn't implement `std::fmt::Display` + --> src/main.rs:24:7 + | +24 | p.outline_print(); + | ^^^^^^^^^^^^^ `Point` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `Point` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `OutlinePrint::outline_print` + --> src/main.rs:3:21 + | +3 | trait OutlinePrint: fmt::Display { + | ^^^^^^^^^^^^ required by this bound in `OutlinePrint::outline_print` +4 | fn outline_print(&self) { + | ------------- required by a bound in this associated function + For more information about this error, try `rustc --explain E0277`. -error: could not compile `traits-example` due to previous error +error: could not compile `traits-example` (bin "traits-example") due to 2 previous errors diff --git a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/src/main.rs b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/src/main.rs old mode 100755 new mode 100644 index a1e2fe4..0e45f3c --- a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/src/main.rs +++ b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/src/main.rs @@ -6,7 +6,7 @@ trait OutlinePrint: fmt::Display { let len = output.len(); println!("{}", "*".repeat(len + 4)); println!("*{}*", " ".repeat(len + 2)); - println!("* {} *", output); + println!("* {output} *"); println!("*{}*", " ".repeat(len + 2)); println!("{}", "*".repeat(len + 4)); } diff --git a/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/Cargo.lock b/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/Cargo.toml b/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/src/main.rs b/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/src/main.rs old mode 100755 new mode 100644 index c7bbb6a..fa5be1c --- a/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/src/main.rs +++ b/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/src/main.rs @@ -4,7 +4,7 @@ trait OutlinePrint: fmt::Display { let len = output.len(); println!("{}", "*".repeat(len + 4)); println!("*{}*", " ".repeat(len + 2)); - println!("* {} *", output); + println!("* {output} *"); println!("*{}*", " ".repeat(len + 2)); println!("{}", "*".repeat(len + 4)); } diff --git a/listings/ch19-advanced-features/no-listing-04-kilometers-alias/Cargo.lock b/listings/ch19-advanced-features/no-listing-04-kilometers-alias/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-04-kilometers-alias/Cargo.toml b/listings/ch19-advanced-features/no-listing-04-kilometers-alias/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-04-kilometers-alias/src/main.rs b/listings/ch19-advanced-features/no-listing-04-kilometers-alias/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-05-write-trait/Cargo.lock b/listings/ch19-advanced-features/no-listing-05-write-trait/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-05-write-trait/Cargo.toml b/listings/ch19-advanced-features/no-listing-05-write-trait/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-05-write-trait/src/lib.rs b/listings/ch19-advanced-features/no-listing-05-write-trait/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.lock b/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.toml b/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs b/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-07-never-type/Cargo.lock b/listings/ch19-advanced-features/no-listing-07-never-type/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-07-never-type/Cargo.toml b/listings/ch19-advanced-features/no-listing-07-never-type/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs b/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/Cargo.lock b/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/Cargo.toml b/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/src/main.rs b/listings/ch19-advanced-features/no-listing-08-match-arms-different-types/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-09-unwrap-definition/Cargo.lock b/listings/ch19-advanced-features/no-listing-09-unwrap-definition/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-09-unwrap-definition/Cargo.toml b/listings/ch19-advanced-features/no-listing-09-unwrap-definition/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-09-unwrap-definition/src/lib.rs b/listings/ch19-advanced-features/no-listing-09-unwrap-definition/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-10-loop-returns-never/Cargo.lock b/listings/ch19-advanced-features/no-listing-10-loop-returns-never/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-10-loop-returns-never/Cargo.toml b/listings/ch19-advanced-features/no-listing-10-loop-returns-never/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-10-loop-returns-never/src/main.rs b/listings/ch19-advanced-features/no-listing-10-loop-returns-never/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-11-cant-create-str/Cargo.lock b/listings/ch19-advanced-features/no-listing-11-cant-create-str/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-11-cant-create-str/Cargo.toml b/listings/ch19-advanced-features/no-listing-11-cant-create-str/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-11-cant-create-str/src/main.rs b/listings/ch19-advanced-features/no-listing-11-cant-create-str/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/Cargo.lock b/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/Cargo.toml b/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/src/lib.rs b/listings/ch19-advanced-features/no-listing-12-generic-fn-definition/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/Cargo.lock b/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/Cargo.toml b/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/src/lib.rs b/listings/ch19-advanced-features/no-listing-13-generic-implicit-sized-bound/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/Cargo.lock b/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/Cargo.toml b/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/src/lib.rs b/listings/ch19-advanced-features/no-listing-14-generic-maybe-sized/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-15-map-closure/Cargo.lock b/listings/ch19-advanced-features/no-listing-15-map-closure/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-15-map-closure/Cargo.toml b/listings/ch19-advanced-features/no-listing-15-map-closure/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-15-map-closure/src/main.rs b/listings/ch19-advanced-features/no-listing-15-map-closure/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-16-map-function/Cargo.lock b/listings/ch19-advanced-features/no-listing-16-map-function/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-16-map-function/Cargo.toml b/listings/ch19-advanced-features/no-listing-16-map-function/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-16-map-function/src/main.rs b/listings/ch19-advanced-features/no-listing-16-map-function/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-17-map-initializer/Cargo.lock b/listings/ch19-advanced-features/no-listing-17-map-initializer/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-17-map-initializer/Cargo.toml b/listings/ch19-advanced-features/no-listing-17-map-initializer/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-17-map-initializer/src/main.rs b/listings/ch19-advanced-features/no-listing-17-map-initializer/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/Cargo.lock b/listings/ch19-advanced-features/no-listing-18-returns-closure/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/Cargo.toml b/listings/ch19-advanced-features/no-listing-18-returns-closure/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt old mode 100755 new mode 100644 index 104f2cf..bc736bd --- a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt +++ b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt @@ -6,11 +6,15 @@ error[E0746]: return type cannot have an unboxed trait object 1 | fn returns_closure() -> dyn Fn(i32) -> i32 { | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see -help: use `impl Fn(i32) -> i32` as the return type, as all return paths are of type `[closure@src/lib.rs:2:5: 2:8]`, which implements `Fn(i32) -> i32` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | 1 | fn returns_closure() -> impl Fn(i32) -> i32 { - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` + | +1 ~ fn returns_closure() -> Box i32> { +2 ~ Box::new(|x| x + 1) + | For more information about this error, try `rustc --explain E0746`. -error: could not compile `functions-example` due to previous error +error: could not compile `functions-example` (lib) due to 1 previous error diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/src/lib.rs b/listings/ch19-advanced-features/no-listing-18-returns-closure/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/Cargo.lock b/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/Cargo.toml b/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/src/lib.rs b/listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/Cargo.lock b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/Cargo.toml b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/src/lib.rs b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/Cargo.lock b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/Cargo.toml b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/src/main.rs b/listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/pancakes/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/Cargo.lock b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/Cargo.toml b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.lock b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.lock old mode 100755 new mode 100644 index 9a38c8a..6be987b --- a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.lock +++ b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.lock @@ -1,46 +1,46 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "hello_macro_derive" version = "0.1.0" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "syn" -version = "1.0.14" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.toml b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.toml old mode 100755 new mode 100644 index aa076ac..ed9e917 --- a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.toml +++ b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" proc-macro = true [dependencies] -syn = "1.0" +syn = "2.0" quote = "1.0" diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/src/lib.rs b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/src/lib.rs old mode 100755 new mode 100644 index 5e0b96c..654b6be --- a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/src/lib.rs +++ b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/hello_macro_derive/src/lib.rs @@ -1,6 +1,5 @@ use proc_macro::TokenStream; use quote::quote; -use syn; #[proc_macro_derive(HelloMacro)] pub fn hello_macro_derive(input: TokenStream) -> TokenStream { diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/src/lib.rs b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/src/main.rs b/listings/ch19-advanced-features/no-listing-21-pancakes/hello_macro/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.lock b/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.lock old mode 100755 new mode 100644 index dee23ec..3849f15 --- a/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.lock +++ b/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "hello_macro" version = "0.1.0" @@ -8,51 +10,49 @@ version = "0.1.0" name = "hello_macro_derive" version = "0.1.0" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "pancakes" version = "0.1.0" dependencies = [ - "hello_macro 0.1.0", - "hello_macro_derive 0.1.0", + "hello_macro", + "hello_macro_derive", ] [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "syn" -version = "1.0.14" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.toml b/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/src/main.rs b/listings/ch19-advanced-features/no-listing-21-pancakes/pancakes/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/Cargo.lock b/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/Cargo.toml b/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/src/lib.rs b/listings/ch19-advanced-features/no-listing-22-iterator-on-counter/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/output-only-01-missing-unsafe/Cargo.lock b/listings/ch19-advanced-features/output-only-01-missing-unsafe/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/output-only-01-missing-unsafe/Cargo.toml b/listings/ch19-advanced-features/output-only-01-missing-unsafe/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt b/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt old mode 100755 new mode 100644 index 5886bc6..b14994c --- a/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt +++ b/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example) -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block +error[E0133]: call to unsafe function `dangerous` is unsafe and requires unsafe function or block --> src/main.rs:4:5 | 4 | dangerous(); @@ -9,4 +9,4 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or = note: consult the function's documentation for information on how to avoid undefined behavior For more information about this error, try `rustc --explain E0133`. -error: could not compile `unsafe-example` due to previous error +error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error diff --git a/listings/ch19-advanced-features/output-only-01-missing-unsafe/src/main.rs b/listings/ch19-advanced-features/output-only-01-missing-unsafe/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-01/Cargo.lock b/listings/ch20-web-server/listing-20-01/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-01/Cargo.toml b/listings/ch20-web-server/listing-20-01/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-01/src/main.rs b/listings/ch20-web-server/listing-20-01/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-02/Cargo.lock b/listings/ch20-web-server/listing-20-02/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-02/Cargo.toml b/listings/ch20-web-server/listing-20-02/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-02/src/main.rs b/listings/ch20-web-server/listing-20-02/src/main.rs old mode 100755 new mode 100644 index 7240c73..f139846 --- a/listings/ch20-web-server/listing-20-02/src/main.rs +++ b/listings/ch20-web-server/listing-20-02/src/main.rs @@ -21,5 +21,5 @@ fn handle_connection(mut stream: TcpStream) { .take_while(|line| !line.is_empty()) .collect(); - println!("Request: {:#?}", http_request); + println!("Request: {http_request:#?}"); } diff --git a/listings/ch20-web-server/listing-20-03/Cargo.lock b/listings/ch20-web-server/listing-20-03/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-03/Cargo.toml b/listings/ch20-web-server/listing-20-03/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-03/src/main.rs b/listings/ch20-web-server/listing-20-03/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-04/Cargo.lock b/listings/ch20-web-server/listing-20-04/Cargo.lock deleted file mode 100755 index f2d069f..0000000 --- a/listings/ch20-web-server/listing-20-04/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "hello" -version = "0.1.0" - diff --git a/listings/ch20-web-server/listing-20-04/Cargo.toml b/listings/ch20-web-server/listing-20-04/Cargo.toml deleted file mode 100755 index fe61947..0000000 --- a/listings/ch20-web-server/listing-20-04/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hello" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch20-web-server/listing-20-04/hello.html b/listings/ch20-web-server/listing-20-04/hello.html deleted file mode 100755 index fe442d6..0000000 --- a/listings/ch20-web-server/listing-20-04/hello.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Hello!

-

Hi from Rust

- - diff --git a/listings/ch20-web-server/listing-20-04/src/main.rs b/listings/ch20-web-server/listing-20-04/src/main.rs deleted file mode 100755 index 818eac9..0000000 --- a/listings/ch20-web-server/listing-20-04/src/main.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - handle_connection(stream); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - - stream.read(&mut buffer).unwrap(); - - let response = "HTTP/1.1 200 OK\r\n\r\n"; - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-05/Cargo.lock b/listings/ch20-web-server/listing-20-05/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-05/Cargo.toml b/listings/ch20-web-server/listing-20-05/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-05/hello.html b/listings/ch20-web-server/listing-20-05/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-05/src/main.rs b/listings/ch20-web-server/listing-20-05/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-06/Cargo.lock b/listings/ch20-web-server/listing-20-06/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-06/Cargo.toml b/listings/ch20-web-server/listing-20-06/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-06/hello.html b/listings/ch20-web-server/listing-20-06/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-06/src/main.rs b/listings/ch20-web-server/listing-20-06/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-07/404.html b/listings/ch20-web-server/listing-20-07/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-07/Cargo.lock b/listings/ch20-web-server/listing-20-07/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-07/Cargo.toml b/listings/ch20-web-server/listing-20-07/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-07/hello.html b/listings/ch20-web-server/listing-20-07/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-07/src/main.rs b/listings/ch20-web-server/listing-20-07/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-08/404.html b/listings/ch20-web-server/listing-20-08/404.html deleted file mode 100755 index 88d8e91..0000000 --- a/listings/ch20-web-server/listing-20-08/404.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Oops!

-

Sorry, I don't know what you're asking for.

- - diff --git a/listings/ch20-web-server/listing-20-08/Cargo.lock b/listings/ch20-web-server/listing-20-08/Cargo.lock deleted file mode 100755 index f2d069f..0000000 --- a/listings/ch20-web-server/listing-20-08/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "hello" -version = "0.1.0" - diff --git a/listings/ch20-web-server/listing-20-08/Cargo.toml b/listings/ch20-web-server/listing-20-08/Cargo.toml deleted file mode 100755 index fe61947..0000000 --- a/listings/ch20-web-server/listing-20-08/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hello" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch20-web-server/listing-20-08/hello.html b/listings/ch20-web-server/listing-20-08/hello.html deleted file mode 100755 index fe442d6..0000000 --- a/listings/ch20-web-server/listing-20-08/hello.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Hello!

-

Hi from Rust

- - diff --git a/listings/ch20-web-server/listing-20-08/src/main.rs b/listings/ch20-web-server/listing-20-08/src/main.rs deleted file mode 100755 index 6dfaa97..0000000 --- a/listings/ch20-web-server/listing-20-08/src/main.rs +++ /dev/null @@ -1,47 +0,0 @@ -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - handle_connection(stream); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - - if buffer.starts_with(get) { - let contents = fs::read_to_string("hello.html").unwrap(); - - let response = format!( - "HTTP/1.1 200 OK\r\nContent-Length: {}\r\n\r\n{}", - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); - } else { - let status_line = "HTTP/1.1 404 NOT FOUND"; - let contents = fs::read_to_string("404.html").unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); - } -} diff --git a/listings/ch20-web-server/listing-20-09/404.html b/listings/ch20-web-server/listing-20-09/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-09/Cargo.lock b/listings/ch20-web-server/listing-20-09/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-09/Cargo.toml b/listings/ch20-web-server/listing-20-09/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-09/hello.html b/listings/ch20-web-server/listing-20-09/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-09/src/main.rs b/listings/ch20-web-server/listing-20-09/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-10/404.html b/listings/ch20-web-server/listing-20-10/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-10/Cargo.lock b/listings/ch20-web-server/listing-20-10/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-10/Cargo.toml b/listings/ch20-web-server/listing-20-10/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-10/hello.html b/listings/ch20-web-server/listing-20-10/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-10/src/main.rs b/listings/ch20-web-server/listing-20-10/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-11/404.html b/listings/ch20-web-server/listing-20-11/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-11/Cargo.lock b/listings/ch20-web-server/listing-20-11/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-11/Cargo.toml b/listings/ch20-web-server/listing-20-11/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-11/hello.html b/listings/ch20-web-server/listing-20-11/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-11/src/main.rs b/listings/ch20-web-server/listing-20-11/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-12/404.html b/listings/ch20-web-server/listing-20-12/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-12/Cargo.lock b/listings/ch20-web-server/listing-20-12/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-12/Cargo.toml b/listings/ch20-web-server/listing-20-12/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-12/hello.html b/listings/ch20-web-server/listing-20-12/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-12/output.txt b/listings/ch20-web-server/listing-20-12/output.txt old mode 100755 new mode 100644 index 57a58b9..0faae99 --- a/listings/ch20-web-server/listing-20-12/output.txt +++ b/listings/ch20-web-server/listing-20-12/output.txt @@ -7,4 +7,4 @@ error[E0433]: failed to resolve: use of undeclared type `ThreadPool` | ^^^^^^^^^^ use of undeclared type `ThreadPool` For more information about this error, try `rustc --explain E0433`. -error: could not compile `hello` due to previous error +error: could not compile `hello` (bin "hello") due to 1 previous error diff --git a/listings/ch20-web-server/listing-20-12/src/main.rs b/listings/ch20-web-server/listing-20-12/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/404.html b/listings/ch20-web-server/listing-20-13/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/Cargo.lock b/listings/ch20-web-server/listing-20-13/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/Cargo.toml b/listings/ch20-web-server/listing-20-13/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/hello.html b/listings/ch20-web-server/listing-20-13/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/src/bin/main.rs b/listings/ch20-web-server/listing-20-13/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-13/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-13/src/lib.rs b/listings/ch20-web-server/listing-20-13/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-13/src/main.rs b/listings/ch20-web-server/listing-20-13/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/404.html b/listings/ch20-web-server/listing-20-14/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/Cargo.lock b/listings/ch20-web-server/listing-20-14/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/Cargo.toml b/listings/ch20-web-server/listing-20-14/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/hello.html b/listings/ch20-web-server/listing-20-14/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/src/bin/main.rs b/listings/ch20-web-server/listing-20-14/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-14/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-14/src/lib.rs b/listings/ch20-web-server/listing-20-14/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-14/src/main.rs b/listings/ch20-web-server/listing-20-14/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/404.html b/listings/ch20-web-server/listing-20-15/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/Cargo.lock b/listings/ch20-web-server/listing-20-15/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/Cargo.toml b/listings/ch20-web-server/listing-20-15/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/hello.html b/listings/ch20-web-server/listing-20-15/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/src/bin/main.rs b/listings/ch20-web-server/listing-20-15/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-15/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-15/src/lib.rs b/listings/ch20-web-server/listing-20-15/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-15/src/main.rs b/listings/ch20-web-server/listing-20-15/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/404.html b/listings/ch20-web-server/listing-20-16/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/Cargo.lock b/listings/ch20-web-server/listing-20-16/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/Cargo.toml b/listings/ch20-web-server/listing-20-16/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/hello.html b/listings/ch20-web-server/listing-20-16/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/src/bin/main.rs b/listings/ch20-web-server/listing-20-16/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-16/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-16/src/lib.rs b/listings/ch20-web-server/listing-20-16/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-16/src/main.rs b/listings/ch20-web-server/listing-20-16/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/404.html b/listings/ch20-web-server/listing-20-17/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/Cargo.lock b/listings/ch20-web-server/listing-20-17/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/Cargo.toml b/listings/ch20-web-server/listing-20-17/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/hello.html b/listings/ch20-web-server/listing-20-17/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/output.txt b/listings/ch20-web-server/listing-20-17/output.txt old mode 100755 new mode 100644 index 8bedfec..cd06ca1 --- a/listings/ch20-web-server/listing-20-17/output.txt +++ b/listings/ch20-web-server/listing-20-17/output.txt @@ -6,8 +6,16 @@ error[E0382]: use of moved value: `receiver` 21 | let (sender, receiver) = mpsc::channel(); | -------- move occurs because `receiver` has type `std::sync::mpsc::Receiver`, which does not implement the `Copy` trait ... +25 | for id in 0..size { + | ----------------- inside of this loop 26 | workers.push(Worker::new(id, receiver)); | ^^^^^^^^ value moved here, in previous iteration of loop + | +note: consider changing this parameter type in method `new` to borrow instead if owning the value isn't necessary + --> src/lib.rs:47:33 + | +47 | fn new(id: usize, receiver: mpsc::Receiver) -> Worker { + | --- in this method ^^^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value For more information about this error, try `rustc --explain E0382`. -error: could not compile `hello` due to previous error +error: could not compile `hello` (lib) due to 1 previous error diff --git a/listings/ch20-web-server/listing-20-17/src/bin/main.rs b/listings/ch20-web-server/listing-20-17/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-17/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-17/src/lib.rs b/listings/ch20-web-server/listing-20-17/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-17/src/main.rs b/listings/ch20-web-server/listing-20-17/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/404.html b/listings/ch20-web-server/listing-20-18/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/Cargo.lock b/listings/ch20-web-server/listing-20-18/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/Cargo.toml b/listings/ch20-web-server/listing-20-18/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/hello.html b/listings/ch20-web-server/listing-20-18/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/src/bin/main.rs b/listings/ch20-web-server/listing-20-18/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-18/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-18/src/lib.rs b/listings/ch20-web-server/listing-20-18/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-18/src/main.rs b/listings/ch20-web-server/listing-20-18/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/404.html b/listings/ch20-web-server/listing-20-19/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/Cargo.lock b/listings/ch20-web-server/listing-20-19/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/Cargo.toml b/listings/ch20-web-server/listing-20-19/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/hello.html b/listings/ch20-web-server/listing-20-19/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/src/bin/main.rs b/listings/ch20-web-server/listing-20-19/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-19/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-19/src/lib.rs b/listings/ch20-web-server/listing-20-19/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-19/src/main.rs b/listings/ch20-web-server/listing-20-19/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/404.html b/listings/ch20-web-server/listing-20-20/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/Cargo.lock b/listings/ch20-web-server/listing-20-20/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/Cargo.toml b/listings/ch20-web-server/listing-20-20/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/hello.html b/listings/ch20-web-server/listing-20-20/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/src/bin/main.rs b/listings/ch20-web-server/listing-20-20/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-20/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-20/src/lib.rs b/listings/ch20-web-server/listing-20-20/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-20/src/main.rs b/listings/ch20-web-server/listing-20-20/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/404.html b/listings/ch20-web-server/listing-20-21/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/Cargo.lock b/listings/ch20-web-server/listing-20-21/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/Cargo.toml b/listings/ch20-web-server/listing-20-21/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/hello.html b/listings/ch20-web-server/listing-20-21/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/src/bin/main.rs b/listings/ch20-web-server/listing-20-21/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-21/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-21/src/lib.rs b/listings/ch20-web-server/listing-20-21/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-21/src/main.rs b/listings/ch20-web-server/listing-20-21/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/404.html b/listings/ch20-web-server/listing-20-22/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/Cargo.lock b/listings/ch20-web-server/listing-20-22/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/Cargo.toml b/listings/ch20-web-server/listing-20-22/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/hello.html b/listings/ch20-web-server/listing-20-22/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/output.txt b/listings/ch20-web-server/listing-20-22/output.txt old mode 100755 new mode 100644 index a6c9e8d..08a28cc --- a/listings/ch20-web-server/listing-20-22/output.txt +++ b/listings/ch20-web-server/listing-20-22/output.txt @@ -8,7 +8,8 @@ error[E0507]: cannot move out of `worker.thread` which is behind a mutable refer | | | move occurs because `worker.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait | -note: this function takes ownership of the receiver `self`, which moves `worker.thread` +note: `JoinHandle::::join` takes ownership of the receiver `self`, which moves `worker.thread` + --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:1657:17 For more information about this error, try `rustc --explain E0507`. -error: could not compile `hello` due to previous error +error: could not compile `hello` (lib) due to 1 previous error diff --git a/listings/ch20-web-server/listing-20-22/src/bin/main.rs b/listings/ch20-web-server/listing-20-22/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-22/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-22/src/lib.rs b/listings/ch20-web-server/listing-20-22/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-22/src/main.rs b/listings/ch20-web-server/listing-20-22/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/404.html b/listings/ch20-web-server/listing-20-23/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/Cargo.lock b/listings/ch20-web-server/listing-20-23/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/Cargo.toml b/listings/ch20-web-server/listing-20-23/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/hello.html b/listings/ch20-web-server/listing-20-23/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/src/bin/main.rs b/listings/ch20-web-server/listing-20-23/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-23/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-23/src/lib.rs b/listings/ch20-web-server/listing-20-23/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-23/src/main.rs b/listings/ch20-web-server/listing-20-23/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/404.html b/listings/ch20-web-server/listing-20-24/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/Cargo.lock b/listings/ch20-web-server/listing-20-24/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/Cargo.toml b/listings/ch20-web-server/listing-20-24/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/hello.html b/listings/ch20-web-server/listing-20-24/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/src/bin/main.rs b/listings/ch20-web-server/listing-20-24/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/listing-20-24/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-24/src/lib.rs b/listings/ch20-web-server/listing-20-24/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-24/src/main.rs b/listings/ch20-web-server/listing-20-24/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/404.html b/listings/ch20-web-server/listing-20-25/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/Cargo.lock b/listings/ch20-web-server/listing-20-25/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/Cargo.toml b/listings/ch20-web-server/listing-20-25/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/hello.html b/listings/ch20-web-server/listing-20-25/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/src/bin/main.rs b/listings/ch20-web-server/listing-20-25/src/bin/main.rs deleted file mode 100755 index 3b314bc..0000000 --- a/listings/ch20-web-server/listing-20-25/src/bin/main.rs +++ /dev/null @@ -1,53 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -// ANCHOR: here -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming().take(2) { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } - - println!("Shutting down."); -} -// ANCHOR_END: here - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/listing-20-25/src/lib.rs b/listings/ch20-web-server/listing-20-25/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/listing-20-25/src/main.rs b/listings/ch20-web-server/listing-20-25/src/main.rs old mode 100755 new mode 100644 index a649ff1..86e8d9e --- a/listings/ch20-web-server/listing-20-25/src/main.rs +++ b/listings/ch20-web-server/listing-20-25/src/main.rs @@ -1,10 +1,11 @@ use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; +use std::{ + fs, + io::{prelude::*, BufReader}, + net::{TcpListener, TcpStream}, + thread, + time::Duration, +}; // ANCHOR: here fn main() { @@ -24,30 +25,23 @@ fn main() { // ANCHOR_END: here fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); + let buf_reader = BufReader::new(&mut stream); + let request_line = buf_reader.lines().next().unwrap().unwrap(); - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") + let (status_line, filename) = match &request_line[..] { + "GET / HTTP/1.1" => ("HTTP/1.1 200 OK", "hello.html"), + "GET /sleep HTTP/1.1" => { + thread::sleep(Duration::from_secs(5)); + ("HTTP/1.1 200 OK", "hello.html") + } + _ => ("HTTP/1.1 404 NOT FOUND", "404.html"), }; let contents = fs::read_to_string(filename).unwrap(); + let length = contents.len(); - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); + let response = + format!("{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}"); stream.write_all(response.as_bytes()).unwrap(); - stream.flush().unwrap(); } diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/404.html b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/Cargo.lock b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/Cargo.toml b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/hello.html b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt old mode 100755 new mode 100644 index fa337b8..85ebfb8 --- a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt +++ b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt @@ -7,4 +7,4 @@ error[E0599]: no function or associated item named `new` found for struct `Threa | ^^^ function or associated item not found in `ThreadPool` For more information about this error, try `rustc --explain E0599`. -error: could not compile `hello` due to previous error +error: could not compile `hello` (bin "hello") due to 1 previous error diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/bin/main.rs b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/bin/main.rs deleted file mode 100755 index d2b8c88..0000000 --- a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/bin/main.rs +++ /dev/null @@ -1,51 +0,0 @@ -// ANCHOR: here -use hello::ThreadPool; -// ANCHOR_END: here -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/lib.rs b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/main.rs b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/404.html b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/Cargo.lock b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/Cargo.toml b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/hello.html b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt old mode 100755 new mode 100644 index 44c8f39..6670418 --- a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt +++ b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt @@ -4,7 +4,7 @@ error[E0599]: no method named `execute` found for struct `ThreadPool` in the cur --> src/main.rs:17:14 | 17 | pool.execute(|| { - | ^^^^^^^ method not found in `ThreadPool` + | -----^^^^^^^ method not found in `ThreadPool` For more information about this error, try `rustc --explain E0599`. -error: could not compile `hello` due to previous error +error: could not compile `hello` (bin "hello") due to 1 previous error diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/bin/main.rs b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/main.rs b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/404.html b/listings/ch20-web-server/no-listing-03-define-execute/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/Cargo.lock b/listings/ch20-web-server/no-listing-03-define-execute/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/Cargo.toml b/listings/ch20-web-server/no-listing-03-define-execute/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/hello.html b/listings/ch20-web-server/no-listing-03-define-execute/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/output.txt b/listings/ch20-web-server/no-listing-03-define-execute/output.txt old mode 100755 new mode 100644 index dc76c43..10d2126 --- a/listings/ch20-web-server/no-listing-03-define-execute/output.txt +++ b/listings/ch20-web-server/no-listing-03-define-execute/output.txt @@ -1,3 +1,3 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) - Finished dev [unoptimized + debuginfo] target(s) in 0.24s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s diff --git a/listings/ch20-web-server/no-listing-03-define-execute/src/bin/main.rs b/listings/ch20-web-server/no-listing-03-define-execute/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-03-define-execute/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs b/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-03-define-execute/src/main.rs b/listings/ch20-web-server/no-listing-03-define-execute/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/404.html b/listings/ch20-web-server/no-listing-04-update-worker-definition/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/Cargo.lock b/listings/ch20-web-server/no-listing-04-update-worker-definition/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/Cargo.toml b/listings/ch20-web-server/no-listing-04-update-worker-definition/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/hello.html b/listings/ch20-web-server/no-listing-04-update-worker-definition/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt b/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt old mode 100755 new mode 100644 index e4c0eeb..ed97073 --- a/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt +++ b/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt @@ -7,6 +7,7 @@ error[E0599]: no method named `join` found for enum `Option` in the current scop | ^^^^ method not found in `Option>` | note: the method `join` exists on the type `JoinHandle<()>` + --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:1657:5 help: consider using `Option::expect` to unwrap the `JoinHandle<()>` value, panicking if the value is an `Option::None` | 52 | worker.thread.expect("REASON").join().unwrap(); @@ -16,7 +17,7 @@ error[E0308]: mismatched types --> src/lib.rs:72:22 | 72 | Worker { id, thread } - | ^^^^^^ expected enum `Option`, found struct `JoinHandle` + | ^^^^^^ expected `Option>`, found `JoinHandle<_>` | = note: expected enum `Option>` found struct `JoinHandle<_>` @@ -27,4 +28,4 @@ help: try wrapping the expression in `Some` Some errors have detailed explanations: E0308, E0599. For more information about an error, try `rustc --explain E0308`. -error: could not compile `hello` due to 2 previous errors +error: could not compile `hello` (lib) due to 2 previous errors diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/src/bin/main.rs b/listings/ch20-web-server/no-listing-04-update-worker-definition/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-04-update-worker-definition/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/src/lib.rs b/listings/ch20-web-server/no-listing-04-update-worker-definition/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/src/main.rs b/listings/ch20-web-server/no-listing-04-update-worker-definition/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/404.html b/listings/ch20-web-server/no-listing-05-fix-worker-new/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/Cargo.lock b/listings/ch20-web-server/no-listing-05-fix-worker-new/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/Cargo.toml b/listings/ch20-web-server/no-listing-05-fix-worker-new/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/hello.html b/listings/ch20-web-server/no-listing-05-fix-worker-new/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/src/bin/main.rs b/listings/ch20-web-server/no-listing-05-fix-worker-new/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-05-fix-worker-new/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/src/lib.rs b/listings/ch20-web-server/no-listing-05-fix-worker-new/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-05-fix-worker-new/src/main.rs b/listings/ch20-web-server/no-listing-05-fix-worker-new/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/404.html b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/Cargo.lock b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/Cargo.toml b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/hello.html b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/bin/main.rs b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/lib.rs b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/main.rs b/listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/main.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/404.html b/listings/ch20-web-server/no-listing-07-define-message-enum/404.html deleted file mode 100755 index 88d8e91..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/404.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Oops!

-

Sorry, I don't know what you're asking for.

- - diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.lock b/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.lock deleted file mode 100755 index f2d069f..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "hello" -version = "0.1.0" - diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.toml b/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.toml deleted file mode 100755 index fe61947..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hello" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/hello.html b/listings/ch20-web-server/no-listing-07-define-message-enum/hello.html deleted file mode 100755 index fe442d6..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/hello.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Hello!

-

Hi from Rust

- - diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/src/bin/main.rs b/listings/ch20-web-server/no-listing-07-define-message-enum/src/bin/main.rs deleted file mode 100755 index 2078ca9..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/src/bin/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs b/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs deleted file mode 100755 index 46fb5f1..0000000 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -use std::sync::mpsc; -use std::sync::Arc; -use std::sync::Mutex; -use std::thread; - -pub struct ThreadPool { - workers: Vec, - sender: mpsc::Sender, -} - -type Job = Box; - -// ANCHOR: here -enum Message { - NewJob(Job), - Terminate, -} -// ANCHOR_END: here - -impl ThreadPool { - /// Create a new ThreadPool. - /// - /// The size is the number of threads in the pool. - /// - /// # Panics - /// - /// The `new` function will panic if the size is zero. - pub fn new(size: usize) -> ThreadPool { - assert!(size > 0); - - let (sender, receiver) = mpsc::channel(); - - let receiver = Arc::new(Mutex::new(receiver)); - - let mut workers = Vec::with_capacity(size); - - for id in 0..size { - workers.push(Worker::new(id, Arc::clone(&receiver))); - } - - ThreadPool { workers, sender } - } - - pub fn execute(&self, f: F) - where - F: FnOnce() + Send + 'static, - { - let job = Box::new(f); - - self.sender.send(job).unwrap(); - } -} - -impl Drop for ThreadPool { - fn drop(&mut self) { - for worker in &mut self.workers { - println!("Shutting down worker {}", worker.id); - - if let Some(thread) = worker.thread.take() { - thread.join().unwrap(); - } - } - } -} - -struct Worker { - id: usize, - thread: Option>, -} - -impl Worker { - fn new(id: usize, receiver: Arc>>) -> Worker { - let thread = thread::spawn(move || loop { - let job = receiver.lock().unwrap().recv().unwrap(); - - println!("Worker {} got a job; executing.", id); - - job(); - }); - - Worker { - id, - thread: Some(thread), - } - } -} diff --git a/listings/ch20-web-server/no-listing-07-final-code/404.html b/listings/ch20-web-server/no-listing-07-final-code/404.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-final-code/Cargo.lock b/listings/ch20-web-server/no-listing-07-final-code/Cargo.lock old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-final-code/Cargo.toml b/listings/ch20-web-server/no-listing-07-final-code/Cargo.toml old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-final-code/hello.html b/listings/ch20-web-server/no-listing-07-final-code/hello.html old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-final-code/src/lib.rs b/listings/ch20-web-server/no-listing-07-final-code/src/lib.rs old mode 100755 new mode 100644 diff --git a/listings/ch20-web-server/no-listing-07-final-code/src/main.rs b/listings/ch20-web-server/no-listing-07-final-code/src/main.rs old mode 100755 new mode 100644 index 3161c2e..b6aa046 --- a/listings/ch20-web-server/no-listing-07-final-code/src/main.rs +++ b/listings/ch20-web-server/no-listing-07-final-code/src/main.rs @@ -1,10 +1,11 @@ use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; +use std::{ + fs, + io::{prelude::*, BufReader}, + net::{TcpListener, TcpStream}, + thread, + time::Duration, +}; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); @@ -22,30 +23,23 @@ fn main() { } fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); + let buf_reader = BufReader::new(&mut stream); + let request_line = buf_reader.lines().next().unwrap().unwrap(); - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") + let (status_line, filename) = match &request_line[..] { + "GET / HTTP/1.1" => ("HTTP/1.1 200 OK", "hello.html"), + "GET /sleep HTTP/1.1" => { + thread::sleep(Duration::from_secs(5)); + ("HTTP/1.1 200 OK", "hello.html") + } + _ => ("HTTP/1.1 404 NOT FOUND", "404.html"), }; let contents = fs::read_to_string(filename).unwrap(); + let length = contents.len(); - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); + let response = + format!("{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}"); stream.write_all(response.as_bytes()).unwrap(); - stream.flush().unwrap(); } diff --git a/listings/ch20-web-server/no-listing-08-final-code/404.html b/listings/ch20-web-server/no-listing-08-final-code/404.html deleted file mode 100755 index 88d8e91..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/404.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Oops!

-

Sorry, I don't know what you're asking for.

- - diff --git a/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock b/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock deleted file mode 100755 index f2d069f..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock +++ /dev/null @@ -1,6 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "hello" -version = "0.1.0" - diff --git a/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml b/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml deleted file mode 100755 index fe61947..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hello" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/listings/ch20-web-server/no-listing-08-final-code/hello.html b/listings/ch20-web-server/no-listing-08-final-code/hello.html deleted file mode 100755 index fe442d6..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/hello.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Hello! - - -

Hello!

-

Hi from Rust

- - diff --git a/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs b/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs deleted file mode 100755 index d3f8754..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs +++ /dev/null @@ -1,51 +0,0 @@ -use hello::ThreadPool; -use std::fs; -use std::io::prelude::*; -use std::net::TcpListener; -use std::net::TcpStream; -use std::thread; -use std::time::Duration; - -fn main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - let pool = ThreadPool::new(4); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - pool.execute(|| { - handle_connection(stream); - }); - } - - println!("Shutting down."); -} - -fn handle_connection(mut stream: TcpStream) { - let mut buffer = [0; 1024]; - stream.read(&mut buffer).unwrap(); - - let get = b"GET / HTTP/1.1\r\n"; - let sleep = b"GET /sleep HTTP/1.1\r\n"; - - let (status_line, filename) = if buffer.starts_with(get) { - ("HTTP/1.1 200 OK", "hello.html") - } else if buffer.starts_with(sleep) { - thread::sleep(Duration::from_secs(5)); - ("HTTP/1.1 200 OK", "hello.html") - } else { - ("HTTP/1.1 404 NOT FOUND", "404.html") - }; - - let contents = fs::read_to_string(filename).unwrap(); - - let response = format!( - "{}\r\nContent-Length: {}\r\n\r\n{}", - status_line, - contents.len(), - contents - ); - - stream.write(response.as_bytes()).unwrap(); - stream.flush().unwrap(); -} diff --git a/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs b/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs deleted file mode 100755 index 68f4263..0000000 --- a/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::sync::mpsc; -use std::sync::Arc; -use std::sync::Mutex; -use std::thread; - -pub struct ThreadPool { - workers: Vec, - sender: mpsc::Sender, -} - -type Job = Box; - -enum Message { - NewJob(Job), - Terminate, -} - -impl ThreadPool { - /// Create a new ThreadPool. - /// - /// The size is the number of threads in the pool. - /// - /// # Panics - /// - /// The `new` function will panic if the size is zero. - pub fn new(size: usize) -> ThreadPool { - assert!(size > 0); - - let (sender, receiver) = mpsc::channel(); - - let receiver = Arc::new(Mutex::new(receiver)); - - let mut workers = Vec::with_capacity(size); - - for id in 0..size { - workers.push(Worker::new(id, Arc::clone(&receiver))); - } - - ThreadPool { workers, sender } - } - - pub fn execute(&self, f: F) - where - F: FnOnce() + Send + 'static, - { - let job = Box::new(f); - - self.sender.send(Message::NewJob(job)).unwrap(); - } -} - -impl Drop for ThreadPool { - fn drop(&mut self) { - println!("Sending terminate message to all workers."); - - for _ in &self.workers { - self.sender.send(Message::Terminate).unwrap(); - } - - println!("Shutting down all workers."); - - for worker in &mut self.workers { - println!("Shutting down worker {}", worker.id); - - if let Some(thread) = worker.thread.take() { - thread.join().unwrap(); - } - } - } -} - -struct Worker { - id: usize, - thread: Option>, -} - -impl Worker { - fn new(id: usize, receiver: Arc>>) -> Worker { - let thread = thread::spawn(move || loop { - let message = receiver.lock().unwrap().recv().unwrap(); - - match message { - Message::NewJob(job) => { - println!("Worker {} got a job; executing.", id); - - job(); - } - Message::Terminate => { - println!("Worker {} was told to terminate.", id); - - break; - } - } - }); - - Worker { - id, - thread: Some(thread), - } - } -} diff --git a/src/ch09-03-to-panic-or-not-to-panic.md b/src/ch09-03-to-panic-or-not-to-panic.md index 0fe484c..2bf5e0f 100644 --- a/src/ch09-03-to-panic-or-not-to-panic.md +++ b/src/ch09-03-to-panic-or-not-to-panic.md @@ -59,7 +59,7 @@ 相反我们可以创建一个新类型来将验证放入创建其实例的函数中,而不是到处重复这些检查。这样就可以安全地在函数签名中使用新类型并相信它们接收到的值。示例 9-13 中展示了一个定义 `Guess` 类型的方法,只有在 `new` 函数接收到 1 到 100 之间的值时才会创建 `Guess` 的实例: ```rust -{{#include ../listings/ch09-error-handling/listing-09-13/src/main.rs:here}} +{{#include ../listings/ch09-error-handling/listing-09-13/src/lib.rs:here}} ``` 示例 9-13:一个 `Guess` 类型,它只在值位于 1 和 100 之间时才继续 diff --git a/src/ch20-01-single-threaded.md b/src/ch20-01-single-threaded.md index 7013dd3..39f472e 100644 --- a/src/ch20-01-single-threaded.md +++ b/src/ch20-01-single-threaded.md @@ -227,7 +227,7 @@ HTTP/1.1 200 OK\r\n\r\n 文件名:404.html ```html -{{#include ../listings/ch20-web-server/listing-20-08/404.html}} +{{#include ../listings/ch20-web-server/listing-20-07/404.html}} ``` 示例 20-8: 任何 404 响应所返回错误页面内容样例