Merge pull request #4883 from nyurik/happy-clippy

chore: Make Clippy happy
This commit is contained in:
Ed Page 2023-05-03 21:13:47 -05:00 committed by GitHub
commit 5fb1b25799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 17 deletions

View file

@ -24,11 +24,12 @@ use std::str::FromStr;
///
/// [^1]: fish completions currently only support named arguments (e.g. -o or --opt), not
/// positional arguments.
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
#[derive(Debug, Default, PartialEq, Eq, Hash, Copy, Clone)]
#[non_exhaustive]
pub enum ValueHint {
/// Default value if hint is not specified. Follows shell default behavior, which is usually
/// auto-completing filenames.
#[default]
Unknown,
/// None of the hints below apply. Disables shell completion for this argument.
Other,
@ -66,12 +67,6 @@ pub enum ValueHint {
EmailAddress,
}
impl Default for ValueHint {
fn default() -> Self {
ValueHint::Unknown
}
}
impl FromStr for ValueHint {
type Err = String;
fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {

View file

@ -164,7 +164,7 @@ pub trait Generator {
/// to see the name of the files generated.
pub fn generate_to<G, S, T>(
gen: G,
cmd: &mut clap::Command,
cmd: &mut Command,
bin_name: S,
out_dir: T,
) -> Result<PathBuf, Error>
@ -181,7 +181,7 @@ where
let path = out_dir.join(file_name);
let mut file = File::create(&path)?;
_generate::<G, S>(gen, cmd, &mut file);
_generate::<G>(gen, cmd, &mut file);
Ok(path)
}
@ -220,21 +220,16 @@ where
/// ```console
/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
/// ```
pub fn generate<G, S>(gen: G, cmd: &mut clap::Command, bin_name: S, buf: &mut dyn Write)
pub fn generate<G, S>(gen: G, cmd: &mut Command, bin_name: S, buf: &mut dyn Write)
where
G: Generator,
S: Into<String>,
{
cmd.set_bin_name(bin_name);
_generate::<G, S>(gen, cmd, buf)
_generate::<G>(gen, cmd, buf)
}
fn _generate<G, S>(gen: G, cmd: &mut clap::Command, buf: &mut dyn Write)
where
G: Generator,
S: Into<String>,
{
fn _generate<G: Generator>(gen: G, cmd: &mut Command, buf: &mut dyn Write) {
cmd.build();
gen.generate(cmd, buf)
}