diff --git a/src/anti_patterns/borrow_clone.md b/src/anti_patterns/borrow_clone.md index 97482b4..cd09f01 100644 --- a/src/anti_patterns/borrow_clone.md +++ b/src/anti_patterns/borrow_clone.md @@ -20,7 +20,7 @@ let y = &mut (x.clone()); // without the x.clone() two lines prior, this line would fail on compile as // x has been borrowed // thanks to x.clone(), x was never borrowed, and this line will run. -println!("{}", x); +println!("{x}"); // perform some action on the borrow to prevent rust from optimizing this //out of existence diff --git a/src/functional/optics.md b/src/functional/optics.md index e281a00..a29c825 100644 --- a/src/functional/optics.md +++ b/src/functional/optics.md @@ -278,7 +278,7 @@ Or do they? fn main() { let a = TestStruct { a: 5, b: "hello".to_string() }; let a_data = a.serialize().to_json(); - println!("Our Test Struct as JSON: {}", a_data); + println!("Our Test Struct as JSON: {a_data}"); let b = TestStruct::deserialize( generated_visitor_for!(TestStruct)::from_json(a_data)); } diff --git a/src/functional/paradigms.md b/src/functional/paradigms.md index 4f7c11b..ecc8e24 100644 --- a/src/functional/paradigms.md +++ b/src/functional/paradigms.md @@ -12,7 +12,7 @@ let mut sum = 0; for i in 1..11 { sum += i; } -println!("{}", sum); +println!("{sum}"); ``` With imperative programs, we have to play compiler to see what is happening. diff --git a/src/idioms/coercion-arguments.md b/src/idioms/coercion-arguments.md index 9291d90..d3d8a54 100644 --- a/src/idioms/coercion-arguments.md +++ b/src/idioms/coercion-arguments.md @@ -111,7 +111,7 @@ fn main() { "Once upon a time, there was a friendly curious crab named Ferris".to_string(); for word in sentence_string.split(' ') { if three_vowels(word) { - println!("{} has three consecutive vowels!", word); + println!("{word} has three consecutive vowels!"); } } } diff --git a/src/idioms/concat-format.md b/src/idioms/concat-format.md index 8053a9c..462606f 100644 --- a/src/idioms/concat-format.md +++ b/src/idioms/concat-format.md @@ -18,7 +18,7 @@ fn say_hello(name: &str) -> String { // result // But using format! is better. - format!("Hello {}!", name) + format!("Hello {name}!") } ``` diff --git a/src/idioms/default.md b/src/idioms/default.md index f383df3..81b0a6c 100644 --- a/src/idioms/default.md +++ b/src/idioms/default.md @@ -44,8 +44,8 @@ fn main() { let mut conf = MyConfiguration::default(); // do something with conf here conf.check = true; - println!("conf = {:#?}", conf); - + println!("conf = {conf:#?}"); + // partial initialization with default values, creates the same instance let conf1 = MyConfiguration { check: true, diff --git a/src/idioms/ffi/errors.md b/src/idioms/ffi/errors.md index d364af1..56900f7 100644 --- a/src/idioms/ffi/errors.md +++ b/src/idioms/ffi/errors.md @@ -71,7 +71,7 @@ pub mod c_api { format!("cannot write to read-only database"); } DatabaseError::IOError(e) => { - format!("I/O Error: {}", e); + format!("I/O Error: {e}"); } DatabaseError::FileCorrupted(s) => { format!("File corrupted, run repair: {}", &s); diff --git a/src/idioms/option-iter.md b/src/idioms/option-iter.md index 350fbb7..031a235 100644 --- a/src/idioms/option-iter.md +++ b/src/idioms/option-iter.md @@ -32,7 +32,7 @@ let turing = Some("Turing"); let logicians = vec!["Curry", "Kleene", "Markov"]; for logician in logicians.iter().chain(turing.iter()) { - println!("{} is a logician", logician); + println!("{logician} is a logician"); } ``` diff --git a/src/idioms/return-consumed-arg-on-error.md b/src/idioms/return-consumed-arg-on-error.md index 75369d2..652fd38 100644 --- a/src/idioms/return-consumed-arg-on-error.md +++ b/src/idioms/return-consumed-arg-on-error.md @@ -36,7 +36,7 @@ fn main() { false }; - println!("success: {}", success); + println!("success: {success}"); } ``` diff --git a/src/patterns/behavioural/interpreter.md b/src/patterns/behavioural/interpreter.md index b6803e3..fb80a66 100644 --- a/src/patterns/behavioural/interpreter.md +++ b/src/patterns/behavioural/interpreter.md @@ -76,7 +76,7 @@ impl<'a> Interpreter<'a> { self.term(out); out.push(op); } else { - panic!("Unexpected symbol '{}'", op); + panic!("Unexpected symbol '{op}'"); } } } @@ -84,7 +84,7 @@ impl<'a> Interpreter<'a> { fn term(&mut self, out: &mut String) { match self.next_char() { Some(ch) if ch.is_digit(10) => out.push(ch), - Some(ch) => panic!("Unexpected symbol '{}'", ch), + Some(ch) => panic!("Unexpected symbol '{ch}'"), None => panic!("Unexpected end of string"), } } @@ -137,7 +137,7 @@ fn main() { assert_eq!(3f64, norm!(x)); assert_eq!(5f64, norm!(x, y)); - assert_eq!(0f64, norm!(0, 0, 0)); + assert_eq!(0f64, norm!(0, 0, 0)); assert_eq!(1f64, norm!(0.5, -0.5, 0.5, -0.5)); } ``` diff --git a/src/patterns/behavioural/strategy.md b/src/patterns/behavioural/strategy.md index f80ea4b..a799ded 100644 --- a/src/patterns/behavioural/strategy.md +++ b/src/patterns/behavioural/strategy.md @@ -60,7 +60,7 @@ struct Text; impl Formatter for Text { fn format(&self, data: &Data, buf: &mut String) { for (k, v) in data { - let entry = format!("{} {}\n", k, v); + let entry = format!("{k} {v}\n"); buf.push_str(&entry); } } diff --git a/src/patterns/structural/compose-structs.md b/src/patterns/structural/compose-structs.md index 62fd30e..4afe410 100644 --- a/src/patterns/structural/compose-structs.md +++ b/src/patterns/structural/compose-structs.md @@ -67,12 +67,12 @@ struct Database { } // print_database can then take ConnectionString, Timeout and Poolsize struct instead -fn print_database(connection_str: ConnectionString, - timeout: Timeout, +fn print_database(connection_str: ConnectionString, + timeout: Timeout, pool_size: PoolSize) { - println!("Connection string: {:?}", connection_str); - println!("Timeout: {:?}", timeout); - println!("Pool size: {:?}", pool_size); + println!("Connection string: {connection_str:?}"); + println!("Timeout: {timeout:?}"); + println!("Pool size: {pool_size:?}"); } fn main() {