From e0859583b3a1209d9ccaee2e02827eae8d9ea49c Mon Sep 17 00:00:00 2001 From: Kivanc Gunalp Date: Sun, 26 Jul 2026 15:34:10 +0000 Subject: [PATCH] Fix clippy collapsible_if in file_io3 cleanup dev-check runs clippy with -D warnings against the solutions, which flagged the nested if let Some(dir_path) = ... { if dir_path.exists() ... } in file_cleanup as collapsible. Combined into a single if-let with a let-chain condition (edition = "2024", so this is available). Verified locally: compiles under --edition 2024, clippy is silent, and the binary still runs cleanly with file size 117 and no leftover files. --- exercises/24_file_io/file_io3.rs | 12 ++++++------ solutions/24_file_io/file_io3.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/exercises/24_file_io/file_io3.rs b/exercises/24_file_io/file_io3.rs index 51df5a82..0f25c03d 100644 --- a/exercises/24_file_io/file_io3.rs +++ b/exercises/24_file_io/file_io3.rs @@ -67,12 +67,12 @@ fn file_cleanup() -> Result<(), std::io::Error> { })?; } - if let Some(dir_path) = path_buffer.parent() { - if dir_path.exists() { - fs::remove_dir(dir_path).inspect(|_| { - println!("Test dir removed"); - })?; - } + if let Some(dir_path) = path_buffer.parent() + && dir_path.exists() + { + fs::remove_dir(dir_path).inspect(|_| { + println!("Test dir removed"); + })?; } Ok(()) diff --git a/solutions/24_file_io/file_io3.rs b/solutions/24_file_io/file_io3.rs index d2b20432..c6a05d4e 100644 --- a/solutions/24_file_io/file_io3.rs +++ b/solutions/24_file_io/file_io3.rs @@ -66,12 +66,12 @@ fn file_cleanup() -> Result<(), std::io::Error> { })?; } - if let Some(dir_path) = path_buffer.parent() { - if dir_path.exists() { - fs::remove_dir(dir_path).inspect(|_| { - println!("Test dir removed"); - })?; - } + if let Some(dir_path) = path_buffer.parent() + && dir_path.exists() + { + fs::remove_dir(dir_path).inspect(|_| { + println!("Test dir removed"); + })?; } Ok(())