Skip to content

Commit

Permalink
Merge pull request #5805 from epage/style
Browse files Browse the repository at this point in the history
fix(complete): Adjust dynamic for MSRV
  • Loading branch information
epage authored Nov 4, 2024
2 parents 5c932b7 + 7c7742c commit f275804
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 1 addition & 3 deletions clap_complete/src/engine/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

Expand Down
1 change: 1 addition & 0 deletions clap_complete/src/engine/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ where
/// ```
pub struct PathCompleter {
current_dir: Option<std::path::PathBuf>,
#[allow(clippy::type_complexity)]
filter: Option<Box<dyn Fn(&std::path::Path) -> bool + Send + Sync>>,
stdio: bool,
}
Expand Down
19 changes: 10 additions & 9 deletions clap_complete/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>();
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}"),
Expand Down

0 comments on commit f275804

Please sign in to comment.