From f55ac5d8fa1d070edc2374b1bcfdbd83bf66f39d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 13 Oct 2022 15:01:58 -0400 Subject: [PATCH] Inline all format arguments The inlined format arguments are a bit easier to understand, especially for those familiar with the other languages (python, js). --- Cargo.toml | 2 +- .../listing-04-01/src/main.rs | 2 +- .../listing-04-03/src/main.rs | 4 ++-- .../listing-04-05/src/main.rs | 2 +- .../no-listing-01-can-mutate-string/src/main.rs | 4 ++-- .../no-listing-04-cant-use-after-move/src/main.rs | 2 +- .../no-listing-05-clone/src/main.rs | 2 +- .../no-listing-06-copy/src/main.rs | 2 +- .../no-listing-07-reference/src/main.rs | 2 +- .../no-listing-08-reference-with-annotations/src/main.rs | 2 +- .../no-listing-13-reference-scope-ends/src/main.rs | 4 ++-- .../no-listing-19-slice-error/src/main.rs | 2 +- .../listing-05-12/src/main.rs | 2 +- .../output-only-02-pretty-debug/src/main.rs | 2 +- .../listing-06-06/src/main.rs | 2 +- .../no-listing-09-variable-in-pattern/src/main.rs | 2 +- .../no-listing-12-if-let/src/main.rs | 2 +- .../no-listing-13-count-and-announce-match/src/main.rs | 2 +- .../src/main.rs | 2 +- .../quick-reference-example/src/main.rs | 2 +- .../ch08-common-collections/listing-08-23/src/main.rs | 2 +- .../ch08-common-collections/listing-08-24/src/main.rs | 2 +- .../ch08-common-collections/listing-08-25/src/main.rs | 2 +- listings/ch09-error-handling/listing-09-04/src/main.rs | 2 +- listings/ch09-error-handling/listing-09-05/src/main.rs | 4 ++-- listings/ch09-error-handling/listing-09-13/src/main.rs | 2 +- .../listing-10-01/src/main.rs | 2 +- .../listing-10-02/src/main.rs | 4 ++-- .../listing-10-03/src/main.rs | 4 ++-- .../listing-10-04/src/main.rs | 4 ++-- .../listing-10-05/src/main.rs | 4 ++-- .../listing-10-16/src/main.rs | 2 +- .../listing-10-17/src/main.rs | 2 +- .../listing-10-18/src/main.rs | 2 +- .../listing-10-19/src/main.rs | 2 +- .../listing-10-20/src/main.rs | 2 +- .../listing-10-21/src/main.rs | 2 +- .../listing-10-22/src/main.rs | 2 +- .../listing-10-23/output.txt | 4 ++-- .../listing-10-23/src/main.rs | 2 +- .../src/main.rs | 2 +- .../no-listing-09-unrelated-lifetime/src/main.rs | 2 +- .../no-listing-10-lifetimes-on-methods/src/main.rs | 2 +- .../src/main.rs | 4 ++-- .../ch11-writing-automated-tests/listing-11-08/src/lib.rs | 2 +- .../ch11-writing-automated-tests/listing-11-10/src/lib.rs | 2 +- .../no-listing-05-greeter/src/lib.rs | 2 +- .../no-listing-08-guess-with-bug/src/lib.rs | 2 +- .../output-only-01-show-output/src/lib.rs | 2 +- listings/ch12-an-io-project/listing-12-02/src/main.rs | 4 ++-- listings/ch12-an-io-project/listing-12-03/src/main.rs | 4 ++-- listings/ch12-an-io-project/listing-12-04/src/main.rs | 4 ++-- listings/ch12-an-io-project/listing-12-05/src/main.rs | 4 ++-- .../ch13-functional-features/listing-13-04/src/main.rs | 8 ++++---- .../ch13-functional-features/listing-13-05/src/main.rs | 4 ++-- .../ch13-functional-features/listing-13-06/src/main.rs | 4 ++-- .../ch13-functional-features/listing-13-07/src/main.rs | 2 +- .../ch13-functional-features/listing-13-08/src/main.rs | 2 +- .../ch13-functional-features/listing-13-09/src/main.rs | 2 +- .../ch13-functional-features/listing-13-11/src/main.rs | 2 +- listings/ch15-smart-pointers/listing-15-01/src/main.rs | 2 +- listings/ch15-smart-pointers/listing-15-24/src/main.rs | 6 +++--- .../ch16-fearless-concurrency/listing-16-01/src/main.rs | 4 ++-- .../ch16-fearless-concurrency/listing-16-02/src/main.rs | 4 ++-- .../ch16-fearless-concurrency/listing-16-03/output.txt | 6 +++--- .../ch16-fearless-concurrency/listing-16-03/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-04/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-05/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-08/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-09/output.txt | 4 ++-- .../ch16-fearless-concurrency/listing-16-09/src/main.rs | 4 ++-- .../ch16-fearless-concurrency/listing-16-10/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-11/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-12/src/main.rs | 2 +- .../no-listing-01-join-too-early/src/main.rs | 4 ++-- .../output-only-01-move-drop/output.txt | 4 ++-- .../output-only-01-move-drop/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-02/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-03/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-07/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-09/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-10/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-11/src/main.rs | 4 ++-- .../ch18-patterns-and-matching/listing-18-15/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-17/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-18/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-21/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-22/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-23/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-25/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-26/src/main.rs | 4 ++-- .../ch18-patterns-and-matching/listing-18-27/src/main.rs | 4 ++-- .../ch18-patterns-and-matching/listing-18-29/src/main.rs | 4 ++-- listings/ch19-advanced-features/listing-19-09/src/main.rs | 2 +- listings/ch19-advanced-features/listing-19-10/src/main.rs | 2 +- listings/ch19-advanced-features/listing-19-22/src/main.rs | 2 +- listings/ch19-advanced-features/listing-19-23/src/main.rs | 2 +- listings/ch19-advanced-features/listing-19-27/src/main.rs | 2 +- .../no-listing-02-impl-outlineprint-for-point/src/main.rs | 2 +- .../no-listing-03-impl-display-for-point/src/main.rs | 2 +- listings/ch20-web-server/listing-20-02/src/main.rs | 2 +- src/ch09-02-recoverable-errors-with-result.md | 4 ++-- tools/doc-to-md.sh | 2 +- tools/src/bin/link2print.rs | 4 ++-- 104 files changed, 139 insertions(+), 139 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c59425f920..60bd20b0fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "rust-book" version = "0.0.1" description = "The Rust Book" -edition = "2018" +edition = "2021" [[bin]] name = "concat_chapters" diff --git a/listings/ch04-understanding-ownership/listing-04-01/src/main.rs b/listings/ch04-understanding-ownership/listing-04-01/src/main.rs index 148ad84c97..ebcd3691be 100644 --- a/listings/ch04-understanding-ownership/listing-04-01/src/main.rs +++ b/listings/ch04-understanding-ownership/listing-04-01/src/main.rs @@ -6,4 +6,4 @@ fn main() { // do stuff with s } // this scope is now over, and s is no longer valid // ANCHOR_END: here -} \ No newline at end of file +} diff --git a/listings/ch04-understanding-ownership/listing-04-03/src/main.rs b/listings/ch04-understanding-ownership/listing-04-03/src/main.rs index b001cc5f4a..edf51a947d 100644 --- a/listings/ch04-understanding-ownership/listing-04-03/src/main.rs +++ b/listings/ch04-understanding-ownership/listing-04-03/src/main.rs @@ -14,10 +14,10 @@ fn main() { // special happens. fn takes_ownership(some_string: String) { // some_string comes into scope - println!("{}", some_string); + println!("{some_string}"); } // Here, some_string goes out of scope and `drop` is called. The backing // memory is freed. fn makes_copy(some_integer: i32) { // some_integer comes into scope - println!("{}", some_integer); + println!("{some_integer}"); } // Here, some_integer goes out of scope. Nothing special happens. diff --git a/listings/ch04-understanding-ownership/listing-04-05/src/main.rs b/listings/ch04-understanding-ownership/listing-04-05/src/main.rs index 22aee1419e..2782483a77 100644 --- a/listings/ch04-understanding-ownership/listing-04-05/src/main.rs +++ b/listings/ch04-understanding-ownership/listing-04-05/src/main.rs @@ -3,7 +3,7 @@ fn main() { let (s2, len) = calculate_length(s1); - println!("The length of '{}' is {}.", s2, len); + println!("The length of '{s2}' is {len}."); } fn calculate_length(s: String) -> (String, usize) { 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 index b68f0f1e78..15bc9d9220 100644 --- 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 @@ -4,6 +4,6 @@ fn main() { s.push_str(", world!"); // push_str() appends a literal to a String - println!("{}", s); // This will print `hello, world!` - // ANCHOR_END: here + println!("{s}"); // This will print `hello, world!` + // ANCHOR_END: here } 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 index d0b9f18795..e35f6d8034 100644 --- 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/src/main.rs b/listings/ch04-understanding-ownership/no-listing-05-clone/src/main.rs index 4e61cc1a16..0b65e5f611 100644 --- 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/src/main.rs b/listings/ch04-understanding-ownership/no-listing-06-copy/src/main.rs index 63a1fae248..b6fd2445d0 100644 --- 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/src/main.rs b/listings/ch04-understanding-ownership/no-listing-07-reference/src/main.rs index fd32a5fc95..6f6d5fb239 100644 --- 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/src/main.rs b/listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/src/main.rs index 6686a801c0..964fd233f7 100644 --- 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 @@ -3,7 +3,7 @@ fn main() { let len = calculate_length(&s1); - println!("The length of '{}' is {}.", s1, len); + println!("The length of '{s1}' is {len}."); } // ANCHOR: here 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 index 8619449669..c005414d8e 100644 --- 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 @@ -4,10 +4,10 @@ fn main() { let r1 = &s; // no problem let r2 = &s; // no problem - println!("{} and {}", r1, r2); + println!("{r1} and {r2}"); // variables r1 and r2 will not be used after this point let r3 = &mut s; // no problem - println!("{}", r3); + println!("{r3}"); // ANCHOR_END: here } 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 index 99e04018d2..b23e45f435 100644 --- 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 @@ -18,6 +18,6 @@ fn main() { s.clear(); // error! - println!("the first word is: {}", word); + println!("the first word is: {word}"); } // ANCHOR_END: here 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 index 2ffc4b8e7b..67e0b92a47 100644 --- 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/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 index 84e32aee49..f763b50d3b 100644 --- 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-06/src/main.rs b/listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs index dc2bffb911..0a037517ab 100644 --- 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-09-variable-in-pattern/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-09-variable-in-pattern/src/main.rs index a4d500c11c..298215d405 100644 --- 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-12-if-let/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-12-if-let/src/main.rs index 735086d4ed..7d7254ea0f 100644 --- 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/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-13-count-and-announce-match/src/main.rs index 12c4c0fec1..d0d7d80271 100644 --- 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/src/main.rs b/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs index ba7eda27b4..3bb3630350 100644 --- 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/ch07-managing-growing-projects/quick-reference-example/src/main.rs b/listings/ch07-managing-growing-projects/quick-reference-example/src/main.rs index 7a024a9a0d..0d9a0ca92f 100644 --- 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-23/src/main.rs b/listings/ch08-common-collections/listing-08-23/src/main.rs index e8684cf2b6..29025b4177 100644 --- 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/src/main.rs b/listings/ch08-common-collections/listing-08-24/src/main.rs index 3ad97b57af..013895632e 100644 --- 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/src/main.rs b/listings/ch08-common-collections/listing-08-25/src/main.rs index f3f6aa166d..84dd1cd4ba 100644 --- 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/ch09-error-handling/listing-09-04/src/main.rs b/listings/ch09-error-handling/listing-09-04/src/main.rs index 69da109fe4..832f57f0e6 100644 --- 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/src/main.rs b/listings/ch09-error-handling/listing-09-05/src/main.rs index 83ea01044f..e0bc55c3f1 100644 --- 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-13/src/main.rs b/listings/ch09-error-handling/listing-09-13/src/main.rs index 9e07c1ee25..42b7d32ef6 100644 --- a/listings/ch09-error-handling/listing-09-13/src/main.rs +++ b/listings/ch09-error-handling/listing-09-13/src/main.rs @@ -10,7 +10,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/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 index a4dba7ed43..c9e9bbbd21 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-02/src/main.rs index 8c523a8be3..fd43154a94 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs index 899222909c..1878f5aacc 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-04/src/main.rs index a47e3f232c..ac3b1f7c1e 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/src/main.rs index df33743f78..094eb416a7 100644 --- 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-16/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/main.rs index d71134ea09..773340eabc 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/src/main.rs index e8ca92328a..6679bcf31e 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-18/src/main.rs index 09ae3919cd..634ff9391a 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-19/src/main.rs index 0f076a71db..8b64cd0008 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs index 6af8c9f0da..bf41acd1f1 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/src/main.rs index 09c3a0daaa..7668de1340 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-22/src/main.rs index 836ec72959..fc9ff296cf 100644 --- 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/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/output.txt index 7f31ce02c4..0cf373f8a4 100644 --- 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 @@ -7,8 +7,8 @@ error[E0597]: `string2` 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 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 index 2a6fa5898f..f2e6338625 100644 --- 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/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 index d144305cb0..4c35d90e3a 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs index aca4be0a78..4d596ec434 100644 --- 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/src/main.rs b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs index 32ad530b51..b8222308d1 100644 --- 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 } } 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 index cfafa9a6d3..4b0201fb16 100644 --- 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-08/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs index 9391be5b1f..54e447bb93 100644 --- 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-10/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs index 6fd76ce006..99fc06b8d6 100644 --- 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/no-listing-05-greeter/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs index 3ba3d8819e..433cf148ea 100644 --- 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-08-guess-with-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs index 32540ba83c..0f962fcd79 100644 --- 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/output-only-01-show-output/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-01-show-output/src/lib.rs index 43c4c92f9a..462d224709 100644 --- 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/ch12-an-io-project/listing-12-02/src/main.rs b/listings/ch12-an-io-project/listing-12-02/src/main.rs index ae2fa7bb1b..afc3c3c9f9 100644 --- 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/src/main.rs b/listings/ch12-an-io-project/listing-12-03/src/main.rs index ae2fa7bb1b..afc3c3c9f9 100644 --- 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/src/main.rs b/listings/ch12-an-io-project/listing-12-04/src/main.rs index 944e4300ec..f343249797 100644 --- 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/src/main.rs b/listings/ch12-an-io-project/listing-12-05/src/main.rs index 0615918338..838cacf39a 100644 --- 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/ch13-functional-features/listing-13-04/src/main.rs b/listings/ch13-functional-features/listing-13-04/src/main.rs index 43b91bb30e..19f51a6f71 100644 --- 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/src/main.rs b/listings/ch13-functional-features/listing-13-05/src/main.rs index 37f8130e2c..f6c2a53de6 100644 --- 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/src/main.rs b/listings/ch13-functional-features/listing-13-06/src/main.rs index 2c8e18c9fd..ee9ca04570 100644 --- 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/src/main.rs b/listings/ch13-functional-features/listing-13-07/src/main.rs index 73a25e5f91..e7ab8d3402 100644 --- 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/src/main.rs b/listings/ch13-functional-features/listing-13-08/src/main.rs index 3b9c9cbdfd..48920d39b4 100644 --- a/listings/ch13-functional-features/listing-13-08/src/main.rs +++ b/listings/ch13-functional-features/listing-13-08/src/main.rs @@ -18,5 +18,5 @@ fn main() { sort_operations.push(value); r.width }); - println!("{:#?}", list); + println!("{list:#?}"); } diff --git a/listings/ch13-functional-features/listing-13-09/src/main.rs b/listings/ch13-functional-features/listing-13-09/src/main.rs index a60d6fd3fc..f007e3c04d 100644 --- 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-11/src/main.rs b/listings/ch13-functional-features/listing-13-11/src/main.rs index 712aff4085..b4e85169ab 100644 --- 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/ch15-smart-pointers/listing-15-01/src/main.rs b/listings/ch15-smart-pointers/listing-15-01/src/main.rs index 8da1d905d6..97f04f3858 100644 --- 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-24/src/main.rs b/listings/ch15-smart-pointers/listing-15-24/src/main.rs index e225bd8620..e3dda1a196 100644 --- 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/ch16-fearless-concurrency/listing-16-01/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-01/src/main.rs index 6305a98e3d..ea10ba282a 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-02/src/main.rs index e37607f1d6..33bf53f400 100644 --- 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/output.txt b/listings/ch16-fearless-concurrency/listing-16-03/output.txt index 321bf59d70..3acd5ef098 100644 --- 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 diff --git a/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-03/src/main.rs index defc876482..b2231c5b86 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-04/src/main.rs index 0bccc5f56f..f0a9058a1c 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs index a6547dc4c1..76783e6149 100644 --- 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-08/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs index fbba9167d4..e7ac452dcd 100644 --- 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/output.txt b/listings/ch16-fearless-concurrency/listing-16-09/output.txt index db85185372..2add0095e7 100644 --- a/listings/ch16-fearless-concurrency/listing-16-09/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-09/output.txt @@ -7,8 +7,8 @@ error[E0382]: borrow of moved value: `val` | --- 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) diff --git a/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-09/src/main.rs index 98a8129ab3..fe20d3474a 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-10/src/main.rs index 82b220de45..c9702bd858 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-11/src/main.rs index d92deab5cb..174a5d14bb 100644 --- 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/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-12/src/main.rs index 0c0d6767ad..99ba5b489a 100644 --- 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/no-listing-01-join-too-early/src/main.rs b/listings/ch16-fearless-concurrency/no-listing-01-join-too-early/src/main.rs index 6205e57d33..7023a90f64 100644 --- 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/output-only-01-move-drop/output.txt b/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt index 301a9a44a4..fca5abeb80 100644 --- 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,8 +8,8 @@ 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 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 index 70f659c5f6..cc71cbab0b 100644 --- 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/ch18-patterns-and-matching/listing-18-02/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-02/src/main.rs index 5f75a4f2db..2479d845d6 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-03/src/main.rs index eb922d62cd..218c180635 100644 --- 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-07/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-07/src/main.rs index 4eccb8088c..70069424c6 100644 --- 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-09/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-09/src/main.rs index d6274fc0e1..e378c37032 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-10/src/main.rs index cb81772e0c..2073948e7d 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-11/src/main.rs index db942b7ac7..0552128036 100644 --- 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-15/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-15/src/main.rs index a3138b2277..9407cc16ab 100644 --- 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-17/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-17/src/main.rs index cf1fbe0721..7053860348 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-18/src/main.rs index b776c64c42..2b8877620a 100644 --- 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-21/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-21/src/main.rs index 980610503f..320db62f5f 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-22/src/main.rs index e2faa345bc..9df1492b29 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs index 7a9d9bb36f..491d6c53f8 100644 --- 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-25/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-25/src/main.rs index b90884eb9c..6c3b24b7db 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs index 41fce97950..2566169a7d 100644 --- 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/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-27/src/main.rs index 8386a0ab8f..06fd949964 100644 --- 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-29/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-29/src/main.rs index 3514deb636..e36fda8789 100644 --- 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/ch19-advanced-features/listing-19-09/src/main.rs b/listings/ch19-advanced-features/listing-19-09/src/main.rs index 82a4b4219f..fda5179af7 100644 --- 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/src/main.rs b/listings/ch19-advanced-features/listing-19-10/src/main.rs index e8dab68e0d..b5559fd3a5 100644 --- 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-22/src/main.rs b/listings/ch19-advanced-features/listing-19-22/src/main.rs index febe58b0c5..7069fef179 100644 --- 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/src/main.rs b/listings/ch19-advanced-features/listing-19-23/src/main.rs index eae46c92f3..f8c8366b4c 100644 --- 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-27/src/main.rs b/listings/ch19-advanced-features/listing-19-27/src/main.rs index 91b2cf04bf..312df2412f 100644 --- 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/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 index a1e2fe4c46..0e45f3c283 100644 --- 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/src/main.rs b/listings/ch19-advanced-features/no-listing-03-impl-display-for-point/src/main.rs index c7bbb6a708..fa5be1c7cf 100644 --- 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/ch20-web-server/listing-20-02/src/main.rs b/listings/ch20-web-server/listing-20-02/src/main.rs index 7240c73c7f..f139846c6d 100644 --- 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/src/ch09-02-recoverable-errors-with-result.md b/src/ch09-02-recoverable-errors-with-result.md index 2ee006f09d..2dd864f08c 100644 --- a/src/ch09-02-recoverable-errors-with-result.md +++ b/src/ch09-02-recoverable-errors-with-result.md @@ -147,10 +147,10 @@ the missing file error. > let greeting_file = File::open("hello.txt").unwrap_or_else(|error| { > if error.kind() == ErrorKind::NotFound { > File::create("hello.txt").unwrap_or_else(|error| { -> panic!("Problem creating the file: {:?}", error); +> panic!("Problem creating the file: {error:?}"); > }) > } else { -> panic!("Problem opening the file: {:?}", error); +> panic!("Problem opening the file: {error:?}"); > } > }); > } diff --git a/tools/doc-to-md.sh b/tools/doc-to-md.sh index 8c802a71fa..2649460065 100755 --- a/tools/doc-to-md.sh +++ b/tools/doc-to-md.sh @@ -22,7 +22,7 @@ directory, so all fixes need to be made in `/src/`. unzip -o "tmp/$filename.docx" -d "tmp/$filename" # Convert to markdown with XSL. xsltproc tools/docx-to-md.xsl "tmp/$filename/word/document.xml" | \ - # Hard wrap at 80 chars at word bourdaries. + # Hard wrap at 80 chars at word boundaries. fold -w 80 -s | \ # Remove trailing whitespace and append to the file in the `nostarch` dir for comparison. sed -e "s/ *$//" >> "nostarch/$filename.md" diff --git a/tools/src/bin/link2print.rs b/tools/src/bin/link2print.rs index 1e92ecbccd..c57d788d21 100644 --- a/tools/src/bin/link2print.rs +++ b/tools/src/bin/link2print.rs @@ -71,13 +71,13 @@ fn parse_links((buffer, ref_map): (String, HashMap)) -> String { Some(key) => { match key.as_str() { // `[name][]` - "" => ref_map.get(&name.to_uppercase()).unwrap_or_else(|| panic!("could not find url for the link text `{}`", name)).to_string(), + "" => ref_map.get(&name.to_uppercase()).unwrap_or_else(|| panic!("could not find url for the link text `{name}`")).to_string(), // `[name][reference]` _ => ref_map.get(&key.as_str().to_uppercase()).unwrap_or_else(|| panic!("could not find url for the link text `{}`", key.as_str())).to_string(), } } // `[name]` as reference - None => ref_map.get(&name.to_uppercase()).unwrap_or_else(|| panic!("could not find url for the link text `{}`", name)).to_string(), + None => ref_map.get(&name.to_uppercase()).unwrap_or_else(|| panic!("could not find url for the link text `{name}`")).to_string(), } } };