From 860b722933a0a4b62bca5b059446ce555b8b3fd2 Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Tue, 24 Jan 2023 14:46:42 +0100 Subject: [PATCH] refactoring: use let else instead of match --- src/builtins/ls.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/builtins/ls.rs b/src/builtins/ls.rs index 7822da6..55338f1 100644 --- a/src/builtins/ls.rs +++ b/src/builtins/ls.rs @@ -16,12 +16,9 @@ impl Builtin for Ls { //for entry in entries.by_ref().into_iter() {} for entry in entries { - let entry = match entry { - Ok(e) => e, - Err(_) => { - println!("Couldn't get directory entry"); - continue; - } + let Ok(entry) = entry else { + eprintln!("Couldn't get directory entry"); + continue; }; let file_name = entry.file_name().to_string_lossy().to_string(); let mut file_type = "unknown";