From 1eb6c1e469de2492d823d4739114d8a85cd6660b Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Feb 2025 13:06:11 +0100 Subject: [PATCH 1/2] Update the edition of the solution format checker --- Cargo.toml | 2 +- src/dev/check.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9b29eca05..a3b1d0d734 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ authors = [ ] repository = "https://github.com/rust-lang/rustlings" license = "MIT" -edition = "2024" # On Update: Update the edition of the `rustfmt` command that checks the solutions. +edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and `CARGO_TOML` in `dev new`. rust-version = "1.85" [workspace.dependencies] diff --git a/src/dev/check.rs b/src/dev/check.rs index aacc2f440f..c89c4eb228 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -313,7 +313,7 @@ fn check_solutions( fmt_cmd .arg("--check") .arg("--edition") - .arg("2021") + .arg("2024") .arg("--color") .arg("always") .stdin(Stdio::null()); From 374c3874afcd01ed0c88047589967d568ceac49f Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Feb 2025 13:08:34 +0100 Subject: [PATCH 2/2] Apply 2024 edition formatting to solutions --- solutions/03_if/if1.rs | 6 +----- solutions/11_hashmaps/hashmaps3.rs | 8 +++++--- solutions/16_lifetimes/lifetimes1.rs | 6 +----- solutions/16_lifetimes/lifetimes2.rs | 6 +----- solutions/quizzes/quiz2.rs | 2 +- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/solutions/03_if/if1.rs b/solutions/03_if/if1.rs index 079c671584..8512a60ff1 100644 --- a/solutions/03_if/if1.rs +++ b/solutions/03_if/if1.rs @@ -1,9 +1,5 @@ fn bigger(a: i32, b: i32) -> i32 { - if a > b { - a - } else { - b - } + if a > b { a } else { b } } fn main() { diff --git a/solutions/11_hashmaps/hashmaps3.rs b/solutions/11_hashmaps/hashmaps3.rs index 433b16c331..485bf83034 100644 --- a/solutions/11_hashmaps/hashmaps3.rs +++ b/solutions/11_hashmaps/hashmaps3.rs @@ -60,9 +60,11 @@ England,Spain,1,0"; fn build_scores() { let scores = build_scores_table(RESULTS); - assert!(["England", "France", "Germany", "Italy", "Poland", "Spain"] - .into_iter() - .all(|team_name| scores.contains_key(team_name))); + assert!( + ["England", "France", "Germany", "Italy", "Poland", "Spain"] + .into_iter() + .all(|team_name| scores.contains_key(team_name)) + ); } #[test] diff --git a/solutions/16_lifetimes/lifetimes1.rs b/solutions/16_lifetimes/lifetimes1.rs index ca7b688da5..4f56834f9d 100644 --- a/solutions/16_lifetimes/lifetimes1.rs +++ b/solutions/16_lifetimes/lifetimes1.rs @@ -5,11 +5,7 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { // ^^^^ ^^ ^^ ^^ - if x.len() > y.len() { - x - } else { - y - } + if x.len() > y.len() { x } else { y } } fn main() { diff --git a/solutions/16_lifetimes/lifetimes2.rs b/solutions/16_lifetimes/lifetimes2.rs index b0f2ef1fa3..3ca49093e8 100644 --- a/solutions/16_lifetimes/lifetimes2.rs +++ b/solutions/16_lifetimes/lifetimes2.rs @@ -1,9 +1,5 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { - if x.len() > y.len() { - x - } else { - y - } + if x.len() > y.len() { x } else { y } } fn main() { diff --git a/solutions/quizzes/quiz2.rs b/solutions/quizzes/quiz2.rs index 58cbe4e2a6..8b073b1867 100644 --- a/solutions/quizzes/quiz2.rs +++ b/solutions/quizzes/quiz2.rs @@ -62,8 +62,8 @@ mod tests { // Import `transformer`. use super::my_module::transformer; - use super::my_module::transformer_iter; use super::Command; + use super::my_module::transformer_iter; #[test] fn it_works() {