From 1197d3b5c9c59c4b362977743957da042f233bc9 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 5 Feb 2022 21:36:35 -0500 Subject: [PATCH] Use v1.58 captured ident formatting in examples Per https://github.com/rust-lang/book/issues/3047, use captured identifiers instead of the positional ones for some examples, e.g. ```diff - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); ``` --- .../ch02-guessing-game-tutorial/listing-02-01/src/main.rs | 2 +- .../ch02-guessing-game-tutorial/listing-02-02/src/main.rs | 2 +- .../listing-03-03/src/main.rs | 2 +- .../src/main.rs | 2 +- .../no-listing-34-for-range/src/main.rs | 2 +- .../ch04-understanding-ownership/listing-04-05/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-09-variable-in-pattern/src/main.rs | 2 +- .../no-listing-13-count-and-announce-match/src/main.rs | 2 +- .../src/main.rs | 2 +- .../no-listing-05-greeter/src/lib.rs | 2 +- listings/ch13-functional-features/listing-13-04/src/main.rs | 6 +++--- listings/ch15-smart-pointers/listing-15-11/src/main.rs | 2 +- listings/ch15-smart-pointers/listing-15-12/src/main.rs | 2 +- listings/ch15-smart-pointers/listing-15-13/src/main.rs | 2 +- .../ch16-fearless-concurrency/listing-16-01/src/main.rs | 4 ++-- .../ch16-fearless-concurrency/listing-16-02/src/main.rs | 4 ++-- .../no-listing-01-join-too-early/src/main.rs | 4 ++-- .../ch18-patterns-and-matching/listing-18-01/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-11/src/main.rs | 6 +++--- .../ch18-patterns-and-matching/listing-18-19/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-24/src/main.rs | 2 +- .../ch18-patterns-and-matching/listing-18-27/src/main.rs | 6 +++--- listings/ch20-web-server/listing-20-20/src/lib.rs | 2 +- listings/ch20-web-server/listing-20-21/src/lib.rs | 2 +- listings/ch20-web-server/listing-20-22/src/lib.rs | 2 +- listings/ch20-web-server/listing-20-23/src/lib.rs | 4 ++-- listings/ch20-web-server/listing-20-24/src/lib.rs | 4 ++-- listings/ch20-web-server/listing-20-25/src/lib.rs | 4 ++-- .../no-listing-04-update-worker-definition/src/lib.rs | 2 +- .../ch20-web-server/no-listing-05-fix-worker-new/src/lib.rs | 2 +- .../no-listing-06-fix-threadpool-drop/src/lib.rs | 2 +- .../no-listing-07-define-message-enum/src/lib.rs | 2 +- .../ch20-web-server/no-listing-08-final-code/src/lib.rs | 4 ++-- redirects/loops.md | 6 +++--- 38 files changed, 53 insertions(+), 53 deletions(-) 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 index b822b89ff3..d44e290d70 100644 --- 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/src/main.rs b/listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs index 60fb2a8e5f..b35ed0f2f5 100644 --- a/listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs +++ b/listings/ch02-guessing-game-tutorial/listing-02-02/src/main.rs @@ -11,5 +11,5 @@ fn main() { .read_line(&mut guess) .expect("Failed to read line"); - println!("You guessed: {}", guess); + println!("You guessed: {guess}"); } 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 index 651ed68c8e..ca070c759d 100644 --- a/listings/ch03-common-programming-concepts/listing-03-03/src/main.rs +++ b/listings/ch03-common-programming-concepts/listing-03-03/src/main.rs @@ -2,7 +2,7 @@ fn main() { let mut number = 3; while number != 0 { - println!("{}!", number); + println!("{number}!"); number -= 1; } 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 index 543c2ea45f..b070ccb23c 100644 --- 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 @@ -3,5 +3,5 @@ fn main() { } fn print_labeled_measurement(value: i32, unit_label: char) { - println!("The measurement is: {}{}", value, unit_label); + println!("The measurement is: {value}{unit_label}"); } 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 index e7286a84e4..df5b305bca 100644 --- 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 @@ -1,6 +1,6 @@ fn main() { for number in (1..4).rev() { - println!("{}!", number); + println!("{number}!"); } println!("LIFTOFF!!!"); } 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-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 6e40b8c300..00eafe0894 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/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-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/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/ch13-functional-features/listing-13-04/src/main.rs b/listings/ch13-functional-features/listing-13-04/src/main.rs index fabe0fb01d..b0772a3c54 100644 --- a/listings/ch13-functional-features/listing-13-04/src/main.rs +++ b/listings/ch13-functional-features/listing-13-04/src/main.rs @@ -12,13 +12,13 @@ fn generate_workout(intensity: u32, random_number: u32) { let expensive_result = simulated_expensive_calculation(intensity); if intensity < 25 { - println!("Today, do {} pushups!", expensive_result); - println!("Next, do {} situps!", expensive_result); + println!("Today, do {expensive_result} pushups!"); + println!("Next, do {expensive_result} situps!"); } else { if random_number == 3 { println!("Take a break today! Remember to stay hydrated!"); } else { - println!("Today, run for {} minutes!", expensive_result); + println!("Today, run for {expensive_result} minutes!"); } } } diff --git a/listings/ch15-smart-pointers/listing-15-11/src/main.rs b/listings/ch15-smart-pointers/listing-15-11/src/main.rs index b73ad89c25..77a88c91f5 100644 --- a/listings/ch15-smart-pointers/listing-15-11/src/main.rs +++ b/listings/ch15-smart-pointers/listing-15-11/src/main.rs @@ -1,6 +1,6 @@ // ANCHOR: here fn hello(name: &str) { - println!("Hello, {}!", name); + println!("Hello, {name}!"); } // ANCHOR_END: here diff --git a/listings/ch15-smart-pointers/listing-15-12/src/main.rs b/listings/ch15-smart-pointers/listing-15-12/src/main.rs index 6a3e143cc3..8cd3893cb2 100644 --- a/listings/ch15-smart-pointers/listing-15-12/src/main.rs +++ b/listings/ch15-smart-pointers/listing-15-12/src/main.rs @@ -17,7 +17,7 @@ impl MyBox { } fn hello(name: &str) { - println!("Hello, {}!", name); + println!("Hello, {name}!"); } // ANCHOR: here diff --git a/listings/ch15-smart-pointers/listing-15-13/src/main.rs b/listings/ch15-smart-pointers/listing-15-13/src/main.rs index ef5361c120..9debe2a31f 100644 --- a/listings/ch15-smart-pointers/listing-15-13/src/main.rs +++ b/listings/ch15-smart-pointers/listing-15-13/src/main.rs @@ -17,7 +17,7 @@ impl MyBox { } fn hello(name: &str) { - println!("Hello, {}!", name); + println!("Hello, {name}!"); } // ANCHOR: here 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/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/ch18-patterns-and-matching/listing-18-01/src/main.rs b/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs index d28c369f56..fc87768fb3 100644 --- a/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs @@ -4,7 +4,7 @@ fn main() { let age: Result = "34".parse(); if let Some(color) = favorite_color { - println!("Using your favorite color, {}, as the background", color); + println!("Using your favorite color, {color}, as the background"); } else if is_tuesday { println!("Tuesday is green day!"); } else if let Ok(age) = age { 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 25eaa79ff8..c05258c99d 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 @@ -5,10 +5,10 @@ fn main() { match x { Some(50) => println!("Got 50"), - Some(y) => println!("Matched, y = {:?}", y), - _ => println!("Default case, x = {:?}", x), + Some(y) => println!("Matched, y = {y:?}"), + _ => println!("Default case, x = {x:?}"), } - println!("at the end: x = {:?}, y = {:?}", x, y); + println!("at the end: x = {x:?}, y = {y:?}"); // ANCHOR_END: here } 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 index 59b48c94d8..e28dab111c 100644 --- a/listings/ch18-patterns-and-matching/listing-18-19/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-19/src/main.rs @@ -4,7 +4,7 @@ fn main() { match numbers { (first, _, third, _, fifth) => { - println!("Some numbers: {}, {}, {}", first, third, fifth) + println!("Some numbers: {first}, {third}, {fifth}") } } // ANCHOR_END: here 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 index f22dbe8edf..3f9aaafc24 100644 --- a/listings/ch18-patterns-and-matching/listing-18-24/src/main.rs +++ b/listings/ch18-patterns-and-matching/listing-18-24/src/main.rs @@ -3,7 +3,7 @@ fn main() { match numbers { (first, .., last) => { - println!("Some numbers: {}, {}", first, last); + println!("Some numbers: {first}, {last}"); } } } 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 348e367233..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 @@ -4,9 +4,9 @@ fn main() { match x { Some(50) => println!("Got 50"), - Some(n) if n == y => println!("Matched, n = {}", n), - _ => println!("Default case, x = {:?}", x), + Some(n) if n == y => println!("Matched, n = {n}"), + _ => println!("Default case, x = {x:?}"), } - println!("at the end: x = {:?}, y = {}", x, y); + println!("at the end: x = {x:?}, y = {y}"); } diff --git a/listings/ch20-web-server/listing-20-20/src/lib.rs b/listings/ch20-web-server/listing-20-20/src/lib.rs index 5fdc32e8b0..e31ab53bd4 100644 --- a/listings/ch20-web-server/listing-20-20/src/lib.rs +++ b/listings/ch20-web-server/listing-20-20/src/lib.rs @@ -57,7 +57,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); diff --git a/listings/ch20-web-server/listing-20-21/src/lib.rs b/listings/ch20-web-server/listing-20-21/src/lib.rs index 6bde524885..55647d8539 100644 --- a/listings/ch20-web-server/listing-20-21/src/lib.rs +++ b/listings/ch20-web-server/listing-20-21/src/lib.rs @@ -55,7 +55,7 @@ impl Worker { fn new(id: usize, receiver: Arc>>) -> Worker { let thread = thread::spawn(move || { while let Ok(job) = receiver.lock().unwrap().recv() { - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); } diff --git a/listings/ch20-web-server/listing-20-22/src/lib.rs b/listings/ch20-web-server/listing-20-22/src/lib.rs index 824257898c..76b7a3fcfd 100644 --- a/listings/ch20-web-server/listing-20-22/src/lib.rs +++ b/listings/ch20-web-server/listing-20-22/src/lib.rs @@ -66,7 +66,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); diff --git a/listings/ch20-web-server/listing-20-23/src/lib.rs b/listings/ch20-web-server/listing-20-23/src/lib.rs index 6ccaee73f6..0da9a9c9b5 100644 --- a/listings/ch20-web-server/listing-20-23/src/lib.rs +++ b/listings/ch20-web-server/listing-20-23/src/lib.rs @@ -86,12 +86,12 @@ impl Worker { match message { Message::NewJob(job) => { - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); } Message::Terminate => { - println!("Worker {} was told to terminate.", id); + println!("Worker {id} was told to terminate."); break; } diff --git a/listings/ch20-web-server/listing-20-24/src/lib.rs b/listings/ch20-web-server/listing-20-24/src/lib.rs index 747bff2b1f..e97637397d 100644 --- a/listings/ch20-web-server/listing-20-24/src/lib.rs +++ b/listings/ch20-web-server/listing-20-24/src/lib.rs @@ -83,12 +83,12 @@ impl Worker { match message { Message::NewJob(job) => { - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); } Message::Terminate => { - println!("Worker {} was told to terminate.", id); + println!("Worker {id} was told to terminate."); break; } diff --git a/listings/ch20-web-server/listing-20-25/src/lib.rs b/listings/ch20-web-server/listing-20-25/src/lib.rs index 68f4263057..8b27305dfe 100644 --- a/listings/ch20-web-server/listing-20-25/src/lib.rs +++ b/listings/ch20-web-server/listing-20-25/src/lib.rs @@ -81,12 +81,12 @@ impl Worker { match message { Message::NewJob(job) => { - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); } Message::Terminate => { - println!("Worker {} was told to terminate.", id); + println!("Worker {id} was told to terminate."); break; } 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 index 1098330b3f..1ed8370125 100644 --- 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 @@ -66,7 +66,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); 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 index 6bef23a16d..a9eff802cd 100644 --- 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 @@ -68,7 +68,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); 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 index d5b38a635d..2f5b25b730 100644 --- 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 @@ -68,7 +68,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); 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 index 46fb5f18d2..d4d74dfde3 100644 --- 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 @@ -73,7 +73,7 @@ impl Worker { let thread = thread::spawn(move || loop { let job = receiver.lock().unwrap().recv().unwrap(); - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); }); 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 index 68f4263057..8b27305dfe 100644 --- 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 @@ -81,12 +81,12 @@ impl Worker { match message { Message::NewJob(job) => { - println!("Worker {} got a job; executing.", id); + println!("Worker {id} got a job; executing."); job(); } Message::Terminate => { - println!("Worker {} was told to terminate.", id); + println!("Worker {id} was told to terminate."); break; } diff --git a/redirects/loops.md b/redirects/loops.md index 1686c115ee..30c7d4059f 100644 --- a/redirects/loops.md +++ b/redirects/loops.md @@ -14,17 +14,17 @@ loop { let mut number = 3; while number != 0 { - println!("{}!", number); + println!("{number}!"); number = number - 1; } let a = [10, 20, 30, 40, 50]; for element in a.iter() { - println!("the value is: {}", element); + println!("the value is: {element}"); } ``` --- You can find the latest version of this information -[here](ch03-05-control-flow.html#repetition-with-loops). \ No newline at end of file +[here](ch03-05-control-flow.html#repetition-with-loops).