From 454bdcb039fe4378b9261bf9862663d8715a04cb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 7 Aug 2025 14:58:17 +0200 Subject: [PATCH] clippy: fix warnings from manual_let_else lint --- src/uu/mktemp/src/mktemp.rs | 25 +++++++++++-------------- src/uu/nohup/src/nohup.rs | 5 ++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 90d0e0f78..6008770b7 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -198,20 +198,17 @@ impl Params { // Get the start and end indices of the randomized part of the template. // // For example, if the template is "abcXXXXyz", then `i` is 3 and `j` is 7. - let (i, j) = match find_last_contiguous_block_of_xs(&options.template) { - None => { - let s = match options.suffix { - // If a suffix is specified, the error message includes the template without the suffix. - Some(_) => options - .template - .chars() - .take(options.template.len()) - .collect::(), - None => options.template, - }; - return Err(MkTempError::TooFewXs(s)); - } - Some(indices) => indices, + let Some((i, j)) = find_last_contiguous_block_of_xs(&options.template) else { + let s = match options.suffix { + // If a suffix is specified, the error message includes the template without the suffix. + Some(_) => options + .template + .chars() + .take(options.template.len()) + .collect::(), + None => options.template, + }; + return Err(MkTempError::TooFewXs(s)); }; // Combine the directory given as an option and the prefix of the template. diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 4aa1a47f3..92dc510b5 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -143,9 +143,8 @@ fn find_stdout() -> UResult { Ok(t) } Err(e1) => { - let home = match env::var("HOME") { - Err(_) => return Err(NohupError::OpenFailed(internal_failure_code, e1).into()), - Ok(h) => h, + let Ok(home) = env::var("HOME") else { + return Err(NohupError::OpenFailed(internal_failure_code, e1).into()); }; let mut homeout = PathBuf::from(home); homeout.push(NOHUP_OUT);