From f1ae3c0e4942a82327970dbf4acbfdb41d431808 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 4 Nov 2024 09:44:03 -0600 Subject: [PATCH 1/2] style: Make clippy happy --- clap_complete/src/engine/custom.rs | 1 + clap_complete/src/env/mod.rs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/clap_complete/src/engine/custom.rs b/clap_complete/src/engine/custom.rs index db0eb2a17c9..a81f0b02848 100644 --- a/clap_complete/src/engine/custom.rs +++ b/clap_complete/src/engine/custom.rs @@ -213,6 +213,7 @@ where /// ``` pub struct PathCompleter { current_dir: Option, + #[allow(clippy::type_complexity)] filter: Option bool + Send + Sync>>, stdio: bool, } diff --git a/clap_complete/src/env/mod.rs b/clap_complete/src/env/mod.rs index ea33d8d68a3..2c5049bdb87 100644 --- a/clap_complete/src/env/mod.rs +++ b/clap_complete/src/env/mod.rs @@ -250,15 +250,16 @@ impl<'s, F: Fn() -> clap::Command> CompleteEnv<'s, F> { let name = name.to_string_lossy(); let shell = self.shells.completer(&name).ok_or_else(|| { - let shells = self - .shells - .names() - .enumerate() - .map(|(i, name)| { - let prefix = if i == 0 { "" } else { ", " }; - format!("{prefix}`{name}`") - }) - .collect::(); + let shells = + self.shells + .names() + .enumerate() + .fold(String::new(), |mut seed, (i, name)| { + use std::fmt::Write as _; + let prefix = if i == 0 { "" } else { ", " }; + let _ = write!(&mut seed, "{prefix}`{name}`"); + seed + }); std::io::Error::new( std::io::ErrorKind::Other, format!("unknown shell `{name}`, expected one of {shells}"), From 7c7742cae8b88fd11ec1f4cadbb49713cc03063a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 4 Nov 2024 09:48:16 -0600 Subject: [PATCH 2/2] fix(complete): Adjust dynamic for MSRV --- clap_complete/src/engine/complete.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clap_complete/src/engine/complete.rs b/clap_complete/src/engine/complete.rs index c5ff943dbc5..9907749970d 100644 --- a/clap_complete/src/engine/complete.rs +++ b/clap_complete/src/engine/complete.rs @@ -391,9 +391,7 @@ fn rsplit_delimiter<'s, 'o>( let delimiter = delimiter?; let value = value.ok()?; let pos = value.rfind(delimiter)?; - let (prefix, value) = value - .split_at_checked(pos + delimiter.len_utf8()) - .expect("since delimiter was found, it is within bounds"); + let (prefix, value) = value.split_at(pos + delimiter.len_utf8()); Some((Some(prefix), Ok(value))) }