From 1361e3088224860b143755e9fe1f1d7ce033e476 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Tue, 10 Mar 2026 18:03:39 +0100 Subject: clippy --- src/run/mod.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/run/mod.rs') diff --git a/src/run/mod.rs b/src/run/mod.rs index 6234b96..5666574 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -25,7 +25,7 @@ impl ExecError { pub fn error_message(&self) -> String { match self { ExecError::UnknownVariable(items) => { - format!("unknown variable: {}", String::from_utf8_lossy(&items)) + format!("unknown variable: {}", String::from_utf8_lossy(items)) } ExecError::ExecError(exit_code) => format!("{exit_code}"), ExecError::SpawnIO(cmd, error) => match error.kind() { @@ -43,8 +43,8 @@ impl ExecError { io::ErrorKind::InvalidFilename => { format!("{cmd} is not a valid file name") } - io::ErrorKind::ArgumentListTooLong => format!("too many arguments"), - io::ErrorKind::Interrupted => format!("got interrupted"), + io::ErrorKind::ArgumentListTooLong => String::from("too many arguments"), + io::ErrorKind::Interrupted => String::from("got interrupted"), io::ErrorKind::Unsupported => format!("{cmd} is not supported"), e => format!("I am surprised you can get this error here: {e:?}"), }, @@ -335,18 +335,17 @@ impl parse::Expander for Executor { return Err(ExecError::UnknownVariable(var)); } - if var[0].is_ascii_digit() { - if let Some(x) = String::from_utf8(var.clone()) + if var[0].is_ascii_digit() + && let Some(x) = String::from_utf8(var.clone()) .ok() .and_then(|x| x.parse::().ok()) - { - if let Some(args) = &self.args { - if x < args.len() { - return Ok(args[x].clone()); - } - } else if let Some(arg) = std::env::args_os().skip(x).next() { - return Ok(arg.into_encoded_bytes()); + { + if let Some(args) = &self.args { + if x < args.len() { + return Ok(args[x].clone()); } + } else if let Some(arg) = std::env::args_os().nth(x) { + return Ok(arg.into_encoded_bytes()); } } -- cgit v1.2.3