Skip to content

Commit b2fe59a

Browse files
authored
refactor: if let with match
1 parent a603ee3 commit b2fe59a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,25 +260,29 @@ All the contents from the trash more then {days} days will be deleted permanentl
260260
continue;
261261
}
262262

263-
if ignore {
264-
// not need of seperate function for this
265-
if path.is_dir() {
263+
match (ignore, path.is_dir(), path.is_file()) {
264+
(true, true, _) => {
266265
if let Err(e) = fs::remove_dir_all(&path) {
267266
eprintln!(
268267
"{}",
269268
format!("Error deleting with out moving to trash: {e}").red()
270269
)
271270
}
272-
} else if path.is_file() {
271+
}
272+
(true, false, true) => {
273273
if let Err(e) = fs::remove_file(&path) {
274274
eprintln!(
275275
"{}",
276276
format!("Error deleting with out moving to trash: {e}").red()
277277
)
278278
}
279279
}
280-
} else if let Err(e) = delete(&path) {
281-
eprintln!("{}", format!("Error moving to trash: {e}").red());
280+
(false, _, _) => {
281+
if let Err(e) = delete(&path) {
282+
eprintln!("{}", format!("Error moving to trash: {e}").red());
283+
}
284+
}
285+
_ => {}
282286
}
283287
}
284288
}

0 commit comments

Comments
 (0)