diff --git a/clap_complete/src/shells/elvish.rs b/clap_complete/src/shells/elvish.rs index d2a267f6f79..07da2834802 100644 --- a/clap_complete/src/shells/elvish.rs +++ b/clap_complete/src/shells/elvish.rs @@ -20,8 +20,7 @@ impl Generator for Elvish { .get_bin_name() .expect("crate::generate should have set the bin_name"); - let mut names = vec![]; - let subcommands_cases = generate_inner(cmd, "", &mut names); + let subcommands_cases = generate_inner(cmd, ""); let result = format!( r#" @@ -67,11 +66,7 @@ fn get_tooltip(help: Option<&StyledStr>, data: T) -> String { } } -fn generate_inner<'help>( - p: &Command, - previous_command_name: &str, - names: &mut Vec<&'help str>, -) -> String { +fn generate_inner(p: &Command, previous_command_name: &str) -> String { debug!("generate_inner"); let command_name = if previous_command_name.is_empty() { @@ -135,7 +130,7 @@ fn generate_inner<'help>( ); for subcommand in p.get_subcommands() { - let subcommand_subcommands_cases = generate_inner(subcommand, &command_name, names); + let subcommand_subcommands_cases = generate_inner(subcommand, &command_name); subcommands_cases.push_str(&subcommand_subcommands_cases); } diff --git a/clap_complete/src/shells/powershell.rs b/clap_complete/src/shells/powershell.rs index ae7e4a750cf..0d3a2a55f73 100644 --- a/clap_complete/src/shells/powershell.rs +++ b/clap_complete/src/shells/powershell.rs @@ -20,8 +20,7 @@ impl Generator for PowerShell { .get_bin_name() .expect("crate::generate should have set the bin_name"); - let mut names = vec![]; - let subcommands_cases = generate_inner(cmd, "", &mut names); + let subcommands_cases = generate_inner(cmd, ""); let result = format!( r#" @@ -72,11 +71,7 @@ fn get_tooltip(help: Option<&StyledStr>, data: T) -> String { } } -fn generate_inner<'help>( - p: &Command, - previous_command_name: &str, - names: &mut Vec<&'help str>, -) -> String { +fn generate_inner(p: &Command, previous_command_name: &str) -> String { debug!("generate_inner"); let command_name = if previous_command_name.is_empty() { @@ -171,7 +166,7 @@ fn generate_inner<'help>( ); for subcommand in p.get_subcommands() { - let subcommand_subcommands_cases = generate_inner(subcommand, &command_name, names); + let subcommand_subcommands_cases = generate_inner(subcommand, &command_name); subcommands_cases.push_str(&subcommand_subcommands_cases); } diff --git a/clap_complete/src/shells/zsh.rs b/clap_complete/src/shells/zsh.rs index 9730229a7fc..580de77a2ec 100644 --- a/clap_complete/src/shells/zsh.rs +++ b/clap_complete/src/shells/zsh.rs @@ -646,7 +646,7 @@ fn write_positionals_of(p: &Command) -> String { .replace(']', "\\]") .replace('\'', "'\\''") .replace(':', "\\:"), - value_completion = value_completion(arg).unwrap_or_else(|| "".to_string()) + value_completion = value_completion(arg).unwrap_or_default() ); debug!("write_positionals_of:iter: Wrote...{}", a); diff --git a/clap_complete_fig/src/fig.rs b/clap_complete_fig/src/fig.rs index 135bbd337f4..6a81afaf6f5 100644 --- a/clap_complete_fig/src/fig.rs +++ b/clap_complete_fig/src/fig.rs @@ -32,7 +32,7 @@ impl Generator for Fig { ) .unwrap(); - gen_fig_inner(command, &[], 2, cmd, &mut buffer); + gen_fig_inner(&[], 2, cmd, &mut buffer); write!(&mut buffer, "}};\n\nexport default completion;\n").unwrap(); @@ -51,13 +51,7 @@ fn escape_string(string: &str) -> String { .replace('\r', "") } -fn gen_fig_inner( - root_command: &str, - parent_commands: &[&str], - indent: usize, - cmd: &Command, - buffer: &mut String, -) { +fn gen_fig_inner(parent_commands: &[&str], indent: usize, cmd: &Command, buffer: &mut String) { if cmd.has_subcommands() { write!(buffer, "{:indent$}subcommands: [\n", "", indent = indent).unwrap(); // generate subcommands @@ -113,13 +107,7 @@ fn gen_fig_inner( let mut parent_commands: Vec<_> = parent_commands.into(); parent_commands.push(subcommand.get_name()); - gen_fig_inner( - root_command, - &parent_commands, - indent + 4, - subcommand, - buffer, - ); + gen_fig_inner(&parent_commands, indent + 4, subcommand, buffer); write!(buffer, "{:indent$}}},\n", "", indent = indent + 2).unwrap(); } diff --git a/clap_lex/tests/lexer.rs b/clap_lex/tests/lexer.rs index bdfae2fd91b..d8ceab2fdae 100644 --- a/clap_lex/tests/lexer.rs +++ b/clap_lex/tests/lexer.rs @@ -5,7 +5,7 @@ fn insert() { assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("bin"))); assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("a"))); - raw.insert(&cursor, &["1", "2", "3"]); + raw.insert(&cursor, ["1", "2", "3"]); assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("1"))); assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("2"))); assert_eq!(raw.next_os(&mut cursor), Some(std::ffi::OsStr::new("3"))); diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs index 08da00e73bd..9c400ffe2db 100644 --- a/clap_mangen/src/render.rs +++ b/clap_mangen/src/render.rs @@ -300,7 +300,7 @@ fn option_environment(opt: &clap::Arg) -> Option> { } else if let Some(env) = opt.get_env() { return Some(vec![ roman("May also be specified with the "), - bold(env.to_string_lossy().to_owned()), + bold(env.to_string_lossy().into_owned()), roman(" environment variable. "), ]); } diff --git a/src/builder/command.rs b/src/builder/command.rs index 41a6cc22eb4..203e677a7be 100644 --- a/src/builder/command.rs +++ b/src/builder/command.rs @@ -675,7 +675,7 @@ impl Command { ); debug!("Command::try_get_matches_from_mut: Reinserting command into arguments so subcommand parser matches it"); - raw_args.insert(&cursor, &[&command]); + raw_args.insert(&cursor, [&command]); debug!("Command::try_get_matches_from_mut: Clearing name and bin_name so that displayed command name starts with applet name"); self.name = "".into(); self.bin_name = None; diff --git a/src/builder/os_str.rs b/src/builder/os_str.rs index ba8cd231af4..bb2370debc2 100644 --- a/src/builder/os_str.rs +++ b/src/builder/os_str.rs @@ -116,7 +116,7 @@ impl From<&'static std::ffi::OsStr> for OsStr { impl From<&'_ &'static std::ffi::OsStr> for OsStr { fn from(name: &'_ &'static std::ffi::OsStr) -> Self { - Self::from_static_ref(*name) + Self::from_static_ref(name) } } diff --git a/src/builder/str.rs b/src/builder/str.rs index 75da8f0896e..c6689d31065 100644 --- a/src/builder/str.rs +++ b/src/builder/str.rs @@ -66,7 +66,7 @@ impl From<&'static str> for Str { impl From<&'_ &'static str> for Str { fn from(name: &'_ &'static str) -> Self { - Self::from_static_ref(*name) + Self::from_static_ref(name) } } diff --git a/src/output/help.rs b/src/output/help.rs index 4405d3e68a3..4e4fdbfdcaa 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -18,7 +18,7 @@ pub(crate) fn write_help(writer: &mut StyledStr, cmd: &Command, usage: &Usage<'_ use super::HelpTemplate; if let Some(tmpl) = cmd.get_help_template() { for (style, content) in tmpl.iter() { - if style == None { + if style.is_none() { HelpTemplate::new(writer, cmd, usage, use_long) .write_templated_help(content); } else { diff --git a/src/output/help_template.rs b/src/output/help_template.rs index 3cf693fa880..3db80da7be6 100644 --- a/src/output/help_template.rs +++ b/src/output/help_template.rs @@ -427,7 +427,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> { // If it's NextLineHelp we don't care to compute how long it is because it may be // NextLineHelp on purpose simply *because* it's so long and would throw off all other // args alignment - should_show_arg(self.use_long, *arg) + should_show_arg(self.use_long, arg) }) { if longest_filter(arg) { longest = longest.max(display_width(&arg.to_string())); @@ -674,7 +674,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> { /// Will use next line help on writing args. fn will_args_wrap(&self, args: &[&Arg], longest: usize) -> bool { args.iter() - .filter(|arg| should_show_arg(self.use_long, *arg)) + .filter(|arg| should_show_arg(self.use_long, arg)) .any(|arg| { let spec_vals = &self.spec_vals(arg); self.arg_next_line_help(arg, spec_vals, longest) diff --git a/src/parser/parser.rs b/src/parser/parser.rs index d6198ca5c15..9b7f9a9fa55 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -1573,7 +1573,7 @@ impl<'cmd> Parser<'cmd> { suggested_trailing_arg, Usage::new(self.cmd) .required(&required) - .create_usage_with_title(&*used), + .create_usage_with_title(&used), ) } diff --git a/tests/builder/app_settings.rs b/tests/builder/app_settings.rs index 8cf8b27f8cc..7cfe3443696 100644 --- a/tests/builder/app_settings.rs +++ b/tests/builder/app_settings.rs @@ -315,7 +315,7 @@ Options: .about("tests stuff") .version("1.3") .hide_possible_values(true) - .args(&[ + .args([ arg!(-o --opt "some option").value_parser(["one", "two"]), arg!([arg1] "some pos arg").value_parser(["three", "four"]), ]); @@ -327,7 +327,7 @@ Options: fn stop_delim_values_only_pos_follows() { let r = Command::new("onlypos") .dont_delimit_trailing_values(true) - .args(&[arg!(f: -f "some opt"), arg!([arg] ... "some arg")]) + .args([arg!(f: -f "some opt"), arg!([arg] ... "some arg")]) .try_get_matches_from(vec!["", "--", "-f", "-g,x"]); assert!(r.is_ok(), "{}", r.unwrap_err()); let m = r.unwrap(); @@ -338,7 +338,7 @@ fn stop_delim_values_only_pos_follows() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-f", "-g,x"] + ["-f", "-g,x"] ); } @@ -355,14 +355,14 @@ fn dont_delim_values_trailingvararg() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test", "--foo", "-Wl,-bar"] + ["test", "--foo", "-Wl,-bar"] ); } #[test] fn delim_values_only_pos_follows() { let r = Command::new("onlypos") - .args(&[arg!(f: -f [flag] "some opt"), arg!([arg] ... "some arg")]) + .args([arg!(f: -f [flag] "some opt"), arg!([arg] ... "some arg")]) .try_get_matches_from(vec!["", "--", "-f", "-g,x"]); assert!(r.is_ok(), "{}", r.unwrap_err()); let m = r.unwrap(); @@ -373,7 +373,7 @@ fn delim_values_only_pos_follows() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-f", "-g,x"] + ["-f", "-g,x"] ); } @@ -389,14 +389,14 @@ fn delim_values_trailingvararg() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test", "--foo", "-Wl,-bar"] + ["test", "--foo", "-Wl,-bar"] ); } #[test] fn delim_values_only_pos_follows_with_delim() { let r = Command::new("onlypos") - .args(&[ + .args([ arg!(f: -f [flag] "some opt"), arg!([arg] ... "some arg").value_delimiter(','), ]) @@ -410,7 +410,7 @@ fn delim_values_only_pos_follows_with_delim() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-f", "-g", "x"] + ["-f", "-g", "x"] ); } @@ -430,7 +430,7 @@ fn delim_values_trailingvararg_with_delim() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test", "--foo", "-Wl", "-bar"] + ["test", "--foo", "-Wl", "-bar"] ); } @@ -623,7 +623,7 @@ fn disable_help_subcommand() { #[test] fn dont_collapse_args() { - let cmd = Command::new("clap-test").version("v1.4.8").args(&[ + let cmd = Command::new("clap-test").version("v1.4.8").args([ Arg::new("arg1").help("some"), Arg::new("arg2").help("some"), Arg::new("arg3").help("some"), @@ -1170,7 +1170,7 @@ fn aaos_opts_mult_req_delims() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["some", "other", "one", "two"] + ["some", "other", "one", "two"] ); } @@ -1201,7 +1201,7 @@ fn aaos_opts_mult() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["first", "overrides", "some", "other", "val"] + ["first", "overrides", "some", "other", "val"] ); } @@ -1219,7 +1219,7 @@ fn aaos_pos_mult() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["some", "other", "value"] + ["some", "other", "value"] ); } @@ -1240,7 +1240,7 @@ fn aaos_option_use_delim_false() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["one,two"] + ["one,two"] ); } diff --git a/tests/builder/arg_aliases.rs b/tests/builder/arg_aliases.rs index 062a9bf5154..6f597bd6ea3 100644 --- a/tests/builder/arg_aliases.rs +++ b/tests/builder/arg_aliases.rs @@ -99,15 +99,15 @@ fn get_aliases() { assert!(a.get_short_and_visible_aliases().is_none()); assert_eq!( a.get_long_and_visible_aliases().unwrap(), - &["aliases", "alias4", "alias5", "alias6"] + ["aliases", "alias4", "alias5", "alias6"] ); assert_eq!( a.get_visible_aliases().unwrap(), - &["alias4", "alias5", "alias6"] + ["alias4", "alias5", "alias6"] ); assert_eq!( a.get_all_aliases().unwrap(), - &["alias1", "alias2", "alias3", "alias4", "alias5", "alias6"] + ["alias1", "alias2", "alias3", "alias4", "alias5", "alias6"] ); assert_eq!(a.get_visible_short_aliases().unwrap(), vec!['d', 'e', 'f']); assert_eq!( diff --git a/tests/builder/arg_matches.rs b/tests/builder/arg_matches.rs index 9e28661da59..c6d16df0eea 100644 --- a/tests/builder/arg_matches.rs +++ b/tests/builder/arg_matches.rs @@ -51,7 +51,7 @@ fn ids_ignore_overridden() { fn arg_matches_if_present_wrong_arg() { let m = Command::new("test") .arg(Arg::new("flag").short('f').action(ArgAction::SetTrue)) - .try_get_matches_from(&["test", "-f"]) + .try_get_matches_from(["test", "-f"]) .unwrap(); assert!(*m.get_one::("flag").expect("defaulted by clap")); @@ -64,7 +64,7 @@ fn arg_matches_if_present_wrong_arg() { fn arg_matches_value_of_wrong_arg() { let m = Command::new("test") .arg(Arg::new("opt").short('o').action(ArgAction::Set)) - .try_get_matches_from(&["test", "-o", "val"]) + .try_get_matches_from(["test", "-o", "val"]) .unwrap(); assert_eq!(m.get_one::("opt").map(|v| v.as_str()), Some("val")); @@ -77,7 +77,7 @@ fn arg_matches_value_of_wrong_arg() { fn arg_matches_subcommand_matches_wrong_sub() { let m = Command::new("test") .subcommand(Command::new("speed")) - .try_get_matches_from(&["test", "speed"]) + .try_get_matches_from(["test", "speed"]) .unwrap(); assert!(m.subcommand_matches("speed").is_some()); diff --git a/tests/builder/default_missing_vals.rs b/tests/builder/default_missing_vals.rs index 15447a6e78c..74ac98cae61 100644 --- a/tests/builder/default_missing_vals.rs +++ b/tests/builder/default_missing_vals.rs @@ -176,7 +176,7 @@ fn default_missing_value_flag_value() { .default_missing_value("true"), ); - let m = cmd.clone().try_get_matches_from(&["test"]).unwrap(); + let m = cmd.clone().try_get_matches_from(["test"]).unwrap(); assert!(m.contains_id("flag")); assert_eq!( m.get_one::("flag").map(|v| v.as_str()), @@ -189,7 +189,7 @@ fn default_missing_value_flag_value() { let m = cmd .clone() - .try_get_matches_from(&["test", "--flag"]) + .try_get_matches_from(["test", "--flag"]) .unwrap(); assert!(m.contains_id("flag")); assert_eq!( @@ -203,7 +203,7 @@ fn default_missing_value_flag_value() { let m = cmd .clone() - .try_get_matches_from(&["test", "--flag=true"]) + .try_get_matches_from(["test", "--flag=true"]) .unwrap(); assert!(m.contains_id("flag")); assert_eq!( @@ -215,7 +215,7 @@ fn default_missing_value_flag_value() { clap::parser::ValueSource::CommandLine ); - let m = cmd.try_get_matches_from(&["test", "--flag=false"]).unwrap(); + let m = cmd.try_get_matches_from(["test", "--flag=false"]).unwrap(); assert!(m.contains_id("flag")); assert_eq!( m.get_one::("flag").map(|v| v.as_str()), diff --git a/tests/builder/default_vals.rs b/tests/builder/default_vals.rs index c5f361a8bb2..f9831807707 100644 --- a/tests/builder/default_vals.rs +++ b/tests/builder/default_vals.rs @@ -752,10 +752,10 @@ fn required_groups_with_default_values() { .arg(Arg::new("arg").default_value("value")) .group(ArgGroup::new("group").args(["arg"]).required(true)); - let result = cmd.clone().try_get_matches_from(&["test"]); + let result = cmd.clone().try_get_matches_from(["test"]); assert!(result.is_err()); - let result = cmd.clone().try_get_matches_from(&["test", "value"]); + let result = cmd.clone().try_get_matches_from(["test", "value"]); assert!(result.is_ok(), "{}", result.unwrap_err()); let m = result.unwrap(); assert!(m.contains_id("arg")); @@ -768,10 +768,10 @@ fn required_args_with_default_values() { let cmd = Command::new("test").arg(Arg::new("arg").required(true).default_value("value")); - let result = cmd.clone().try_get_matches_from(&["test"]); + let result = cmd.clone().try_get_matches_from(["test"]); assert!(result.is_err()); - let result = cmd.clone().try_get_matches_from(&["test", "value"]); + let result = cmd.clone().try_get_matches_from(["test", "value"]); assert!(result.is_ok(), "{}", result.unwrap_err()); let m = result.unwrap(); assert!(m.contains_id("arg")); diff --git a/tests/builder/delimiters.rs b/tests/builder/delimiters.rs index d59c190622b..32475f0d647 100644 --- a/tests/builder/delimiters.rs +++ b/tests/builder/delimiters.rs @@ -122,6 +122,6 @@ fn opt_eq_mult_def_delim() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1", "val2", "val3"] + ["val1", "val2", "val3"] ); } diff --git a/tests/builder/derive_order.rs b/tests/builder/derive_order.rs index 07de2757414..fb14bd1f48b 100644 --- a/tests/builder/derive_order.rs +++ b/tests/builder/derive_order.rs @@ -21,7 +21,7 @@ Options: let cmd = Command::new("test") .version("1.2") .next_display_order(None) - .args(&[ + .args([ Arg::new("flag_b") .long("flag_b") .help("first flag") @@ -57,7 +57,7 @@ Options: -V, --version Print version information "; - let cmd = Command::new("test").version("1.2").args(&[ + let cmd = Command::new("test").version("1.2").args([ Arg::new("flag_b") .long("flag_b") .help("first flag") @@ -185,7 +185,7 @@ Options: "; let cmd = Command::new("test").subcommand( - Command::new("sub").version("1.2").args(&[ + Command::new("sub").version("1.2").args([ Arg::new("flag_b") .long("flag_b") .help("first flag") @@ -223,7 +223,7 @@ Options: "; let cmd = Command::new("test").subcommand( - Command::new("sub").version("1.2").args(&[ + Command::new("sub").version("1.2").args([ Arg::new("flag_b") .long("flag_b") .help("first flag") diff --git a/tests/builder/empty_values.rs b/tests/builder/empty_values.rs index d818c0b99ba..1709a5d1963 100644 --- a/tests/builder/empty_values.rs +++ b/tests/builder/empty_values.rs @@ -7,7 +7,7 @@ use super::utils; fn empty_values() { let m = Command::new("config") .arg(Arg::new("config").long("config").action(ArgAction::Set)) - .try_get_matches_from(&["config", "--config", ""]) + .try_get_matches_from(["config", "--config", ""]) .unwrap(); assert_eq!(m.get_one::("config").map(|v| v.as_str()), Some("")); } @@ -16,13 +16,13 @@ fn empty_values() { fn empty_values_with_equals() { let m = Command::new("config") .arg(Arg::new("config").long("config").action(ArgAction::Set)) - .try_get_matches_from(&["config", "--config="]) + .try_get_matches_from(["config", "--config="]) .unwrap(); assert_eq!(m.get_one::("config").map(|v| v.as_str()), Some("")); let m = Command::new("config") .arg(Arg::new("config").short('c').action(ArgAction::Set)) - .try_get_matches_from(&["config", "-c="]) + .try_get_matches_from(["config", "-c="]) .unwrap(); assert_eq!(m.get_one::("config").map(|v| v.as_str()), Some("")) } @@ -36,7 +36,7 @@ fn no_empty_values() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "--config", ""]); + .try_get_matches_from(["config", "--config", ""]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue); @@ -47,7 +47,7 @@ fn no_empty_values() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "-c", ""]); + .try_get_matches_from(["config", "-c", ""]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue) } @@ -61,7 +61,7 @@ fn no_empty_values_with_equals() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "--config="]); + .try_get_matches_from(["config", "--config="]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue); @@ -72,7 +72,7 @@ fn no_empty_values_with_equals() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "-c="]); + .try_get_matches_from(["config", "-c="]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue); } @@ -86,7 +86,7 @@ fn no_empty_values_without_equals() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "--config"]); + .try_get_matches_from(["config", "--config"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue); @@ -97,7 +97,7 @@ fn no_empty_values_without_equals() { .action(ArgAction::Set) .value_parser(clap::builder::NonEmptyStringValueParser::new()), ) - .try_get_matches_from(&["config", "-c"]); + .try_get_matches_from(["config", "-c"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidValue) } @@ -112,7 +112,7 @@ fn no_empty_values_without_equals_but_requires_equals() { .value_parser(clap::builder::NonEmptyStringValueParser::new()) .require_equals(true), ); - let m = cmd.clone().try_get_matches_from(&["config", "--config"]); + let m = cmd.clone().try_get_matches_from(["config", "--config"]); // Should error on no equals rather than empty value. assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::NoEquals); diff --git a/tests/builder/flags.rs b/tests/builder/flags.rs index 05804410d3c..42881671ed3 100644 --- a/tests/builder/flags.rs +++ b/tests/builder/flags.rs @@ -6,7 +6,7 @@ use super::utils; #[test] fn flag_using_short() { let m = Command::new("flag") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), arg!(-c --color "some other flag").action(ArgAction::SetTrue), ]) @@ -73,7 +73,7 @@ fn lots_o_flags_combined() { #[test] fn flag_using_long() { let m = Command::new("flag") - .args(&[ + .args([ arg!(--flag "some flag").action(ArgAction::SetTrue), arg!(--color "some other flag").action(ArgAction::SetTrue), ]) @@ -101,7 +101,7 @@ fn flag_using_long_with_literals() { #[test] fn flag_using_mixed() { let m = Command::new("flag") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), arg!(-c --color "some other flag").action(ArgAction::SetTrue), ]) @@ -111,7 +111,7 @@ fn flag_using_mixed() { assert!(*m.get_one::("color").expect("defaulted by clap")); let m = Command::new("flag") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), arg!(-c --color "some other flag").action(ArgAction::SetTrue), ]) @@ -124,7 +124,7 @@ fn flag_using_mixed() { #[test] fn multiple_flags_in_single() { let m = Command::new("multe_flags") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), arg!(-c --color "some other flag").action(ArgAction::SetTrue), arg!(-d --debug "another other flag").action(ArgAction::SetTrue), diff --git a/tests/builder/global_args.rs b/tests/builder/global_args.rs index 7542b8e1a79..2f4eae0ee4c 100644 --- a/tests/builder/global_args.rs +++ b/tests/builder/global_args.rs @@ -37,7 +37,7 @@ fn propagate_global_arg_in_subcommand_to_subsubcommand_1385() { ) .subcommand(Command::new("sub1a")), ) - .try_get_matches_from(&["foo", "sub1", "--arg1", "v1", "sub1a"]) + .try_get_matches_from(["foo", "sub1", "--arg1", "v1", "sub1a"]) .unwrap(); assert_eq!( "v1", @@ -62,7 +62,7 @@ fn propagate_global_arg_to_subcommand_in_subsubcommand_2053() { .arg(arg!(--"sub-str" ).global(true)) .subcommand(Command::new("test")), ) - .try_get_matches_from(&[ + .try_get_matches_from([ "cmd", "test", "test", @@ -86,7 +86,7 @@ fn propagate_global_arg_to_subcommand_in_subsubcommand_2053() { #[test] fn global_arg_available_in_subcommand() { let m = Command::new("opt") - .args(&[ + .args([ Arg::new("global") .global(true) .long("global") @@ -97,7 +97,7 @@ fn global_arg_available_in_subcommand() { .action(ArgAction::SetTrue), ]) .subcommand(Command::new("ping")) - .try_get_matches_from(&["opt", "ping", "--global"]) + .try_get_matches_from(["opt", "ping", "--global"]) .unwrap(); assert!(*m.get_one::("global").expect("defaulted by clap")); diff --git a/tests/builder/grouped_values.rs b/tests/builder/grouped_values.rs index 67df706ef54..726eac929aa 100644 --- a/tests/builder/grouped_values.rs +++ b/tests/builder/grouped_values.rs @@ -12,7 +12,7 @@ fn grouped_value_works() { .num_args(1..) .action(ArgAction::Append), ) - .try_get_matches_from(&[ + .try_get_matches_from([ "cli", "--option", "fr_FR:mon option 1", @@ -44,7 +44,7 @@ fn issue_1026() { .num_args(1..) .action(ArgAction::Append), ) - .try_get_matches_from(&[ + .try_get_matches_from([ "backup", "-s", "server", "-u", "user", "--target", "target1", "file1", "file2", "file3", "--target", "target2", "file4", "file5", "file6", "file7", "--target", "target3", "file8", @@ -237,7 +237,7 @@ fn issue_2171() { .action(ArgAction::SetTrue), ); - let test_args = &[ + let test_args = [ vec!["reproducer", "-pz", "-p"], vec!["reproducer", "-pzp"], vec!["reproducer", "-zpp"], diff --git a/tests/builder/groups.rs b/tests/builder/groups.rs index 2150a2b6272..b72c1e317a8 100644 --- a/tests/builder/groups.rs +++ b/tests/builder/groups.rs @@ -233,7 +233,7 @@ fn required_group_multiple_args() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["flag", "color"] + ["flag", "color"] ); } @@ -356,14 +356,14 @@ fn issue_1794() { .required(true), ); - let m = cmd.clone().try_get_matches_from(&["cmd", "pos1", "pos2"]).unwrap(); + let m = cmd.clone().try_get_matches_from(["cmd", "pos1", "pos2"]).unwrap(); assert_eq!(m.get_one::("pos1").map(|v| v.as_str()), Some("pos1")); assert_eq!(m.get_one::("pos2").map(|v| v.as_str()), Some("pos2")); assert!(!*m.get_one::("option1").expect("defaulted by clap")); let m = cmd .clone() - .try_get_matches_from(&["cmd", "--option1", "positional"]).unwrap(); + .try_get_matches_from(["cmd", "--option1", "positional"]).unwrap(); assert_eq!(m.get_one::("pos1").map(|v| v.as_str()), None); assert_eq!(m.get_one::("pos2").map(|v| v.as_str()), Some("positional")); assert!(*m.get_one::("option1").expect("defaulted by clap")); diff --git a/tests/builder/help.rs b/tests/builder/help.rs index 72dd3719878..c448f7117e8 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -2515,7 +2515,7 @@ fn override_help_subcommand() { .subcommand(Command::new("help").arg(Arg::new("arg").action(ArgAction::Set))) .subcommand(Command::new("not_help").arg(Arg::new("arg").action(ArgAction::Set))) .disable_help_subcommand(true); - let matches = cmd.try_get_matches_from(&["bar", "help", "foo"]).unwrap(); + let matches = cmd.try_get_matches_from(["bar", "help", "foo"]).unwrap(); assert_eq!( matches .subcommand_matches("help") @@ -2532,7 +2532,7 @@ fn override_help_flag_using_long() { .subcommand(Command::new("help").long_flag("help")) .disable_help_flag(true) .disable_help_subcommand(true); - let matches = cmd.try_get_matches_from(&["foo", "--help"]).unwrap(); + let matches = cmd.try_get_matches_from(["foo", "--help"]).unwrap(); assert!(matches.subcommand_matches("help").is_some()); } @@ -2542,7 +2542,7 @@ fn override_help_flag_using_short() { .disable_help_flag(true) .disable_help_subcommand(true) .subcommand(Command::new("help").short_flag('h')); - let matches = cmd.try_get_matches_from(&["foo", "-h"]).unwrap(); + let matches = cmd.try_get_matches_from(["foo", "-h"]).unwrap(); assert!(matches.subcommand_matches("help").is_some()); } diff --git a/tests/builder/hidden_args.rs b/tests/builder/hidden_args.rs index 8f634321d32..5d70efa35e7 100644 --- a/tests/builder/hidden_args.rs +++ b/tests/builder/hidden_args.rs @@ -20,7 +20,7 @@ fn hide_args() { .author("Kevin K.") .about("tests stuff") .version("1.4") - .args(&[ + .args([ arg!(-f --flag "some flag").hide(true), arg!(-F --flag2 "some other flag"), arg!(--option "some option"), @@ -47,7 +47,7 @@ fn hide_short_args() { .about("hides short args") .author("Steve P.") .version("2.31.2") - .args(&[ + .args([ Arg::new("cfg") .short('c') .long("config") @@ -90,7 +90,7 @@ Options: .about("hides short args") .author("Steve P.") .version("2.31.2") - .args(&[ + .args([ Arg::new("cfg") .short('c') .long("config") @@ -129,7 +129,7 @@ fn hide_long_args() { .about("hides long args") .author("Steve P.") .version("2.31.2") - .args(&[ + .args([ Arg::new("cfg") .short('c') .long("config") @@ -164,7 +164,7 @@ fn hide_long_args_short_help() { .about("hides long args") .author("Steve P.") .version("2.31.2") - .args(&[ + .args([ Arg::new("cfg") .short('c') .long("config") @@ -194,7 +194,7 @@ Options: #[test] fn hide_pos_args() { - let cmd = Command::new("test").version("1.4").args(&[ + let cmd = Command::new("test").version("1.4").args([ Arg::new("pos").help("some pos").hide(true), Arg::new("another").help("another pos"), ]); @@ -254,7 +254,7 @@ fn hide_pos_args_only() { .disable_version_flag(true) .arg(arg!(-h - -help).action(ArgAction::Help).hide(true)) .arg(arg!(-v - -version).hide(true)) - .args(&[Arg::new("pos").help("some pos").hide(true)]); + .args([Arg::new("pos").help("some pos").hide(true)]); utils::assert_output(cmd, "test --help", HIDDEN_POS_ARGS_ONLY, false); } diff --git a/tests/builder/indices.rs b/tests/builder/indices.rs index dfe7d665184..7c5439551e2 100644 --- a/tests/builder/indices.rs +++ b/tests/builder/indices.rs @@ -22,12 +22,9 @@ fn indices_mult_opts() { assert_eq!( m.indices_of("exclude").unwrap().collect::>(), - &[2, 3, 8] - ); - assert_eq!( - m.indices_of("include").unwrap().collect::>(), - &[5, 6] + [2, 3, 8] ); + assert_eq!(m.indices_of("include").unwrap().collect::>(), [5, 6]); } #[test] @@ -89,8 +86,8 @@ fn indices_mult_flags() { .try_get_matches_from(vec!["ind", "-e", "-i", "-e", "-e", "-i"]) .unwrap(); - assert_eq!(m.indices_of("exclude").unwrap().collect::>(), &[4]); - assert_eq!(m.indices_of("include").unwrap().collect::>(), &[5]); + assert_eq!(m.indices_of("exclude").unwrap().collect::>(), [4]); + assert_eq!(m.indices_of("include").unwrap().collect::>(), [5]); } #[test] @@ -102,8 +99,8 @@ fn indices_mult_flags_combined() { .try_get_matches_from(vec!["ind", "-eieei"]) .unwrap(); - assert_eq!(m.indices_of("exclude").unwrap().collect::>(), &[4]); - assert_eq!(m.indices_of("include").unwrap().collect::>(), &[5]); + assert_eq!(m.indices_of("exclude").unwrap().collect::>(), [4]); + assert_eq!(m.indices_of("include").unwrap().collect::>(), [5]); } #[test] @@ -116,9 +113,9 @@ fn indices_mult_flags_opt_combined() { .try_get_matches_from(vec!["ind", "-eieeio", "val"]) .unwrap(); - assert_eq!(m.indices_of("exclude").unwrap().collect::>(), &[4]); - assert_eq!(m.indices_of("include").unwrap().collect::>(), &[5]); - assert_eq!(m.indices_of("option").unwrap().collect::>(), &[7]); + assert_eq!(m.indices_of("exclude").unwrap().collect::>(), [4]); + assert_eq!(m.indices_of("include").unwrap().collect::>(), [5]); + assert_eq!(m.indices_of("option").unwrap().collect::>(), [7]); } #[test] @@ -131,9 +128,9 @@ fn indices_mult_flags_opt_combined_eq() { .try_get_matches_from(vec!["ind", "-eieeio=val"]) .unwrap(); - assert_eq!(m.indices_of("exclude").unwrap().collect::>(), &[4]); - assert_eq!(m.indices_of("include").unwrap().collect::>(), &[5]); - assert_eq!(m.indices_of("option").unwrap().collect::>(), &[7]); + assert_eq!(m.indices_of("exclude").unwrap().collect::>(), [4]); + assert_eq!(m.indices_of("include").unwrap().collect::>(), [5]); + assert_eq!(m.indices_of("option").unwrap().collect::>(), [7]); } #[test] @@ -151,7 +148,7 @@ fn indices_mult_opt_value_delim_eq() { .unwrap(); assert_eq!( m.indices_of("option").unwrap().collect::>(), - &[2, 3, 4] + [2, 3, 4] ); } @@ -167,7 +164,7 @@ fn indices_mult_opt_value_no_delim_eq() { ) .try_get_matches_from(vec!["myapp", "-o=val1,val2,val3"]) .unwrap(); - assert_eq!(m.indices_of("option").unwrap().collect::>(), &[2]); + assert_eq!(m.indices_of("option").unwrap().collect::>(), [2]); } #[test] @@ -179,6 +176,6 @@ fn indices_mult_opt_mult_flag() { .try_get_matches_from(vec!["myapp", "-o", "val1", "-f", "-o", "val2", "-f"]) .unwrap(); - assert_eq!(m.indices_of("option").unwrap().collect::>(), &[2, 5]); - assert_eq!(m.indices_of("flag").unwrap().collect::>(), &[6]); + assert_eq!(m.indices_of("option").unwrap().collect::>(), [2, 5]); + assert_eq!(m.indices_of("flag").unwrap().collect::>(), [6]); } diff --git a/tests/builder/multiple_occurrences.rs b/tests/builder/multiple_occurrences.rs index 09e50e62b2a..4dd3ee1bda0 100644 --- a/tests/builder/multiple_occurrences.rs +++ b/tests/builder/multiple_occurrences.rs @@ -34,14 +34,14 @@ fn multiple_occurrences_of_positional() { let m = cmd .clone() - .try_get_matches_from(&["test"]) + .try_get_matches_from(["test"]) .expect("zero occurrences work"); assert!(!m.contains_id("multi")); assert!(m.get_many::("multi").is_none()); let m = cmd .clone() - .try_get_matches_from(&["test", "one"]) + .try_get_matches_from(["test", "one"]) .expect("single occurrence work"); assert!(m.contains_id("multi")); assert_eq!( @@ -54,7 +54,7 @@ fn multiple_occurrences_of_positional() { let m = cmd .clone() - .try_get_matches_from(&["test", "one", "two", "three", "four"]) + .try_get_matches_from(["test", "one", "two", "three", "four"]) .expect("many occurrences work"); assert!(m.contains_id("multi")); assert_eq!( diff --git a/tests/builder/multiple_values.rs b/tests/builder/multiple_values.rs index 28c3f7ebd48..5eea39bd3e8 100644 --- a/tests/builder/multiple_values.rs +++ b/tests/builder/multiple_values.rs @@ -853,14 +853,14 @@ fn req_delimiter_long() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1"] + ["val1"] ); assert_eq!( m.get_many::("args") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val2", "val3"] + ["val2", "val3"] ); } @@ -890,14 +890,14 @@ fn req_delimiter_long_with_equal() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1"] + ["val1"] ); assert_eq!( m.get_many::("args") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val2", "val3"] + ["val2", "val3"] ); } @@ -927,14 +927,14 @@ fn req_delimiter_short_with_space() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1"] + ["val1"] ); assert_eq!( m.get_many::("args") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val2", "val3"] + ["val2", "val3"] ); } @@ -964,14 +964,14 @@ fn req_delimiter_short_with_no_space() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1"] + ["val1"] ); assert_eq!( m.get_many::("args") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val2", "val3"] + ["val2", "val3"] ); } @@ -1001,14 +1001,14 @@ fn req_delimiter_short_with_equal() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val1"] + ["val1"] ); assert_eq!( m.get_many::("args") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["val2", "val3"] + ["val2", "val3"] ); } @@ -1062,7 +1062,7 @@ fn req_delimiter_complex() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &[ + [ "val2", "val4", "val6", "val8", "val10", "val12", "val13", "val15", "val16", "val18", "val19", "val21", "val22", "val24", "val25", ] @@ -1072,7 +1072,7 @@ fn req_delimiter_complex() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &[ + [ "val1", "val3", "val5", "val7", "val9", "val11", "val14", "val17", "val20", "val23", "val26", ] diff --git a/tests/builder/opts.rs b/tests/builder/opts.rs index f149528c9bb..97bf8f3106a 100644 --- a/tests/builder/opts.rs +++ b/tests/builder/opts.rs @@ -127,7 +127,7 @@ fn stdin_char() { #[test] fn opts_using_short() { let r = Command::new("opts") - .args(&[ + .args([ arg!(f: -f [flag] "some flag"), arg!(c: -c [color] "some other flag"), ]) @@ -189,7 +189,7 @@ fn lots_o_vals() { #[test] fn opts_using_long_space() { let r = Command::new("opts") - .args(&[ + .args([ arg!(--flag [flag] "some flag"), arg!(--color [color] "some other flag"), ]) @@ -211,7 +211,7 @@ fn opts_using_long_space() { #[test] fn opts_using_long_equals() { let r = Command::new("opts") - .args(&[ + .args([ arg!(--flag [flag] "some flag"), arg!(--color [color] "some other flag"), ]) @@ -233,7 +233,7 @@ fn opts_using_long_equals() { #[test] fn opts_using_mixed() { let r = Command::new("opts") - .args(&[ + .args([ arg!(-f --flag [flag] "some flag"), arg!(-c --color [color] "some other flag"), ]) @@ -255,7 +255,7 @@ fn opts_using_mixed() { #[test] fn opts_using_mixed2() { let r = Command::new("opts") - .args(&[ + .args([ arg!(-f --flag [flag] "some flag"), arg!(-c --color [color] "some other flag"), ]) @@ -334,7 +334,7 @@ fn require_delims() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["1", "2"] + ["1", "2"] ); assert!(m.contains_id("file")); assert_eq!( @@ -361,7 +361,7 @@ fn leading_hyphen_pass() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-2", "3"] + ["-2", "3"] ); } @@ -394,7 +394,7 @@ fn leading_hyphen_with_flag_after() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-2", "-f"] + ["-2", "-f"] ); assert!(!*m.get_one::("f").expect("defaulted by clap")); } @@ -413,7 +413,7 @@ fn leading_hyphen_with_flag_before() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-2"] + ["-2"] ); assert!(*m.get_one::("f").expect("defaulted by clap")); } @@ -436,7 +436,7 @@ fn leading_hyphen_with_only_pos_follows() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["-2"] + ["-2"] ); assert_eq!(m.get_one::("arg").map(|v| v.as_str()), Some("val")); } @@ -576,7 +576,7 @@ For more information try '--help' fn short_non_ascii_no_space() { let matches = Command::new("cmd") .arg(arg!(opt: -'磨' ).required(true)) - .try_get_matches_from(&["test", "-磨VALUE"]) + .try_get_matches_from(["test", "-磨VALUE"]) .unwrap(); assert_eq!( @@ -592,7 +592,7 @@ fn short_non_ascii_no_space() { fn short_eq_val_starts_with_eq() { let matches = Command::new("cmd") .arg(arg!(opt: -f ).required(true)) - .try_get_matches_from(&["test", "-f==value"]) + .try_get_matches_from(["test", "-f==value"]) .unwrap(); assert_eq!( @@ -608,7 +608,7 @@ fn short_eq_val_starts_with_eq() { fn long_eq_val_starts_with_eq() { let matches = Command::new("cmd") .arg(arg!(opt: --foo ).required(true)) - .try_get_matches_from(&["test", "--foo==value"]) + .try_get_matches_from(["test", "--foo==value"]) .unwrap(); assert_eq!( @@ -625,7 +625,7 @@ fn issue_2022_get_flags_misuse() { let cmd = Command::new("test") .next_help_heading(Some("test")) .arg(Arg::new("a").long("a").default_value("32")); - let matches = cmd.try_get_matches_from(&[""]).unwrap(); + let matches = cmd.try_get_matches_from([""]).unwrap(); assert!(matches.get_one::("a").map(|v| v.as_str()).is_some()) } @@ -634,7 +634,7 @@ fn issue_2279() { let before_help_heading = Command::new("cmd") .arg(Arg::new("foo").short('f').default_value("bar")) .next_help_heading(Some("This causes default_value to be ignored")) - .try_get_matches_from(&[""]) + .try_get_matches_from([""]) .unwrap(); assert_eq!( @@ -647,7 +647,7 @@ fn issue_2279() { let after_help_heading = Command::new("cmd") .next_help_heading(Some("This causes default_value to be ignored")) .arg(Arg::new("foo").short('f').default_value("bar")) - .try_get_matches_from(&[""]) + .try_get_matches_from([""]) .unwrap(); assert_eq!( @@ -672,7 +672,7 @@ fn infer_long_arg() { let matches = cmd .clone() - .try_get_matches_from(&["test", "--racec=hello"]) + .try_get_matches_from(["test", "--racec=hello"]) .unwrap(); assert!(!*matches .get_one::("racetrack") @@ -684,7 +684,7 @@ fn infer_long_arg() { let matches = cmd .clone() - .try_get_matches_from(&["test", "--racet"]) + .try_get_matches_from(["test", "--racet"]) .unwrap(); assert!(*matches .get_one::("racetrack") @@ -696,7 +696,7 @@ fn infer_long_arg() { let matches = cmd .clone() - .try_get_matches_from(&["test", "--auto"]) + .try_get_matches_from(["test", "--auto"]) .unwrap(); assert!(*matches .get_one::("racetrack") @@ -710,9 +710,9 @@ fn infer_long_arg() { .infer_long_args(true) .arg(Arg::new("arg").long("arg").action(ArgAction::SetTrue)); - let matches = cmd.clone().try_get_matches_from(&["test", "--"]).unwrap(); + let matches = cmd.clone().try_get_matches_from(["test", "--"]).unwrap(); assert!(!*matches.get_one::("arg").expect("defaulted by clap")); - let matches = cmd.clone().try_get_matches_from(&["test", "--a"]).unwrap(); + let matches = cmd.clone().try_get_matches_from(["test", "--a"]).unwrap(); assert!(*matches.get_one::("arg").expect("defaulted by clap")); } diff --git a/tests/builder/positionals.rs b/tests/builder/positionals.rs index 70fb37f3a79..b931b119abe 100644 --- a/tests/builder/positionals.rs +++ b/tests/builder/positionals.rs @@ -3,7 +3,7 @@ use clap::{arg, error::ErrorKind, Arg, ArgAction, Command}; #[test] fn only_pos_follow() { let r = Command::new("onlypos") - .args(&[arg!(f: -f [flag] "some opt"), arg!([arg] "some arg")]) + .args([arg!(f: -f [flag] "some opt"), arg!([arg] "some arg")]) .try_get_matches_from(vec!["", "--", "-f"]); assert!(r.is_ok(), "{}", r.unwrap_err()); let m = r.unwrap(); @@ -40,7 +40,7 @@ fn issue_946() { #[test] fn positional() { let r = Command::new("positional") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), Arg::new("positional").index(1), ]) @@ -57,7 +57,7 @@ fn positional() { ); let m = Command::new("positional") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), Arg::new("positional").index(1), ]) @@ -116,7 +116,7 @@ fn lots_o_vals() { #[test] fn positional_multiple() { let r = Command::new("positional_multiple") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), Arg::new("positional") .index(1) @@ -133,14 +133,14 @@ fn positional_multiple() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test1", "test2", "test3"] + ["test1", "test2", "test3"] ); } #[test] fn positional_multiple_3() { let r = Command::new("positional_multiple") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), Arg::new("positional") .index(1) @@ -157,14 +157,14 @@ fn positional_multiple_3() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test1", "test2", "test3"] + ["test1", "test2", "test3"] ); } #[test] fn positional_multiple_2() { let result = Command::new("positional_multiple") - .args(&[arg!(-f --flag "some flag"), Arg::new("positional").index(1)]) + .args([arg!(-f --flag "some flag"), Arg::new("positional").index(1)]) .try_get_matches_from(vec!["", "-f", "test1", "test2", "test3"]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -174,7 +174,7 @@ fn positional_multiple_2() { #[test] fn positional_possible_values() { let r = Command::new("positional_possible_values") - .args(&[ + .args([ arg!(-f --flag "some flag").action(ArgAction::SetTrue), Arg::new("positional").index(1).value_parser(["test123"]), ]) @@ -188,7 +188,7 @@ fn positional_possible_values() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["test123"] + ["test123"] ); } @@ -285,7 +285,7 @@ fn last_positional() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["arg"] + ["arg"] ); } diff --git a/tests/builder/posix_compatible.rs b/tests/builder/posix_compatible.rs index f5e7739da98..880c58c8f10 100644 --- a/tests/builder/posix_compatible.rs +++ b/tests/builder/posix_compatible.rs @@ -326,14 +326,14 @@ fn incremental_override() { .action(ArgAction::SetTrue), ); let m = cmd - .try_get_matches_from_mut(&["test", "--name=ahmed", "--no-name", "--name=ali"]) + .try_get_matches_from_mut(["test", "--name=ahmed", "--no-name", "--name=ali"]) .unwrap(); assert_eq!( m.get_many::("name") .unwrap() .map(|v| v.as_str()) .collect::>(), - &["ali"] + ["ali"] ); assert!(!*m.get_one::("no-name").expect("defaulted by clap")); } diff --git a/tests/builder/possible_values.rs b/tests/builder/possible_values.rs index d7d6a6d5ce8..99d231e4a24 100644 --- a/tests/builder/possible_values.rs +++ b/tests/builder/possible_values.rs @@ -452,7 +452,7 @@ fn ignore_case_multiple() { .unwrap() .map(|v| v.as_str()) .collect::>(), - &["TeSt123", "teST123", "tESt321"] + ["TeSt123", "teST123", "tESt321"] ); } diff --git a/tests/builder/require.rs b/tests/builder/require.rs index 915b89076a0..e84a71debf6 100644 --- a/tests/builder/require.rs +++ b/tests/builder/require.rs @@ -1126,7 +1126,7 @@ For more information try '--help' #[test] fn issue_1158_conflicting_requirements_rev() { - let res = issue_1158_app().try_get_matches_from(&["", "--config", "some.conf"]); + let res = issue_1158_app().try_get_matches_from(["", "--config", "some.conf"]); assert!(res.is_ok(), "{}", res.unwrap_err()); } @@ -1153,7 +1153,7 @@ fn issue_1643_args_mutually_require_each_other() { .requires("relation_id"), ); - cmd.try_get_matches_from(&["test", "-u", "hello", "-r", "farewell"]) + cmd.try_get_matches_from(["test", "-u", "hello", "-r", "farewell"]) .unwrap(); } @@ -1167,7 +1167,7 @@ fn short_flag_require_equals_with_minvals_zero() { .require_equals(true), ) .arg(Arg::new("unique").short('u').action(ArgAction::SetTrue)) - .try_get_matches_from(&["foo", "-cu"]) + .try_get_matches_from(["foo", "-cu"]) .unwrap(); assert!(m.contains_id("check")); assert!(*m.get_one::("unique").expect("defaulted by clap")); @@ -1190,7 +1190,7 @@ fn issue_2624() { .long("unique") .action(ArgAction::SetTrue), ) - .try_get_matches_from(&["foo", "-cu"]) + .try_get_matches_from(["foo", "-cu"]) .unwrap(); assert!(matches.contains_id("check")); assert!(*matches diff --git a/tests/builder/subcommands.rs b/tests/builder/subcommands.rs index 8437aef01af..3e5e0f41965 100644 --- a/tests/builder/subcommands.rs +++ b/tests/builder/subcommands.rs @@ -234,7 +234,7 @@ fn replace() { .subcommand( Command::new("module").subcommand(Command::new("install").about("Install module")), ) - .replace("install", &["module", "install"]) + .replace("install", ["module", "install"]) .try_get_matches_from(vec!["prog", "install"]) .unwrap(); @@ -403,19 +403,19 @@ fn issue_2494_subcommand_is_present() { let m = cmd .clone() - .try_get_matches_from(&["opt", "--global", "global"]) + .try_get_matches_from(["opt", "--global", "global"]) .unwrap(); assert_eq!(m.subcommand_name().unwrap(), "global"); assert!(*m.get_one::("global").expect("defaulted by clap")); let m = cmd .clone() - .try_get_matches_from(&["opt", "--global"]) + .try_get_matches_from(["opt", "--global"]) .unwrap(); assert!(m.subcommand_name().is_none()); assert!(*m.get_one::("global").expect("defaulted by clap")); - let m = cmd.try_get_matches_from(&["opt", "global"]).unwrap(); + let m = cmd.try_get_matches_from(["opt", "global"]).unwrap(); assert_eq!(m.subcommand_name().unwrap(), "global"); assert!(!*m.get_one::("global").expect("defaulted by clap")); } @@ -452,15 +452,15 @@ fn busybox_like_multicall() { let m = cmd .clone() - .try_get_matches_from(&["busybox", "true"]) + .try_get_matches_from(["busybox", "true"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("busybox")); assert_eq!(m.subcommand().unwrap().1.subcommand_name(), Some("true")); - let m = cmd.clone().try_get_matches_from(&["true"]).unwrap(); + let m = cmd.clone().try_get_matches_from(["true"]).unwrap(); assert_eq!(m.subcommand_name(), Some("true")); - let m = cmd.clone().try_get_matches_from(&["a.out"]); + let m = cmd.clone().try_get_matches_from(["a.out"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidSubcommand); } @@ -472,24 +472,21 @@ fn hostname_like_multicall() { .subcommand(Command::new("hostname")) .subcommand(Command::new("dnsdomainname")); - let m = cmd.clone().try_get_matches_from(&["hostname"]).unwrap(); + let m = cmd.clone().try_get_matches_from(["hostname"]).unwrap(); assert_eq!(m.subcommand_name(), Some("hostname")); - let m = cmd - .clone() - .try_get_matches_from(&["dnsdomainname"]) - .unwrap(); + let m = cmd.clone().try_get_matches_from(["dnsdomainname"]).unwrap(); assert_eq!(m.subcommand_name(), Some("dnsdomainname")); - let m = cmd.clone().try_get_matches_from(&["a.out"]); + let m = cmd.clone().try_get_matches_from(["a.out"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidSubcommand); - let m = cmd.try_get_matches_from_mut(&["hostname", "hostname"]); + let m = cmd.try_get_matches_from_mut(["hostname", "hostname"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); - let m = cmd.try_get_matches_from(&["hostname", "dnsdomainname"]); + let m = cmd.try_get_matches_from(["hostname", "dnsdomainname"]); assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); } @@ -504,7 +501,7 @@ fn bad_multicall_command_error() { .subcommand(Command::new("foo")) .subcommand(Command::new("bar")); - let err = cmd.clone().try_get_matches_from(&["world"]).unwrap_err(); + let err = cmd.clone().try_get_matches_from(["world"]).unwrap_err(); assert_eq!(err.kind(), ErrorKind::InvalidSubcommand); static HELLO_EXPECTED: &str = "\ error: The subcommand 'world' wasn't recognized @@ -517,7 +514,7 @@ For more information try 'help' #[cfg(feature = "suggestions")] { - let err = cmd.clone().try_get_matches_from(&["baz"]).unwrap_err(); + let err = cmd.clone().try_get_matches_from(["baz"]).unwrap_err(); assert_eq!(err.kind(), ErrorKind::InvalidSubcommand); static BAZ_EXPECTED: &str = "\ error: The subcommand 'baz' wasn't recognized @@ -537,13 +534,13 @@ For more information try 'help' let err = cmd .clone() - .try_get_matches_from(&["foo", "--help"]) + .try_get_matches_from(["foo", "--help"]) .unwrap_err(); assert_eq!(err.kind(), ErrorKind::DisplayHelp); let err = cmd .clone() - .try_get_matches_from(&["foo", "--version"]) + .try_get_matches_from(["foo", "--version"]) .unwrap_err(); assert_eq!(err.kind(), ErrorKind::DisplayVersion); } diff --git a/tests/builder/tests.rs b/tests/builder/tests.rs index 433e39ef6eb..072a8773cc3 100644 --- a/tests/builder/tests.rs +++ b/tests/builder/tests.rs @@ -252,7 +252,7 @@ fn create_app() { #[test] fn add_multiple_arg() { let _ = Command::new("test") - .args(&[Arg::new("test").short('s'), Arg::new("test2").short('l')]) + .args([Arg::new("test").short('s'), Arg::new("test2").short('l')]) .try_get_matches_from(vec![""]) .unwrap(); } diff --git a/tests/builder/unique_args.rs b/tests/builder/unique_args.rs index 19833f0c16f..84fbfd7bc74 100644 --- a/tests/builder/unique_args.rs +++ b/tests/builder/unique_args.rs @@ -5,7 +5,7 @@ fn unique_arg_names() { use clap::{Arg, Command}; let _ = Command::new("some") - .args(&[Arg::new("arg1").short('a'), Arg::new("arg1").short('b')]) + .args([Arg::new("arg1").short('a'), Arg::new("arg1").short('b')]) .try_get_matches(); } @@ -16,7 +16,7 @@ fn unique_arg_shorts() { use clap::{Arg, Command}; let _ = Command::new("some") - .args(&[Arg::new("arg1").short('a'), Arg::new("arg2").short('a')]) + .args([Arg::new("arg1").short('a'), Arg::new("arg2").short('a')]) .try_get_matches(); } @@ -27,6 +27,6 @@ fn unique_arg_longs() { use clap::{Arg, Command}; let _ = Command::new("some") - .args(&[Arg::new("arg1").long("long"), Arg::new("arg2").long("long")]) + .args([Arg::new("arg1").long("long"), Arg::new("arg2").long("long")]) .try_get_matches(); } diff --git a/tests/derive/arguments.rs b/tests/derive/arguments.rs index 5ccea034edf..9bc3cb8186c 100644 --- a/tests/derive/arguments.rs +++ b/tests/derive/arguments.rs @@ -24,10 +24,10 @@ fn required_argument() { } assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "42"]).unwrap() + Opt::try_parse_from(["test", "42"]).unwrap() ); - assert!(Opt::try_parse_from(&["test"]).is_err()); - assert!(Opt::try_parse_from(&["test", "42", "24"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); + assert!(Opt::try_parse_from(["test", "42", "24"]).is_err()); } #[test] @@ -39,10 +39,10 @@ fn argument_with_default() { } assert_eq!( Opt { arg: 24 }, - Opt::try_parse_from(&["test", "24"]).unwrap() + Opt::try_parse_from(["test", "24"]).unwrap() ); - assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(&["test"]).unwrap()); - assert!(Opt::try_parse_from(&["test", "42", "24"]).is_err()); + assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(["test"]).unwrap()); + assert!(Opt::try_parse_from(["test", "42", "24"]).is_err()); } #[test] @@ -58,7 +58,7 @@ fn auto_value_name() { // Ensure the implicit `num_vals` is just 1 assert_eq!( Opt { my_special_arg: 10 }, - Opt::try_parse_from(&["test", "10"]).unwrap() + Opt::try_parse_from(["test", "10"]).unwrap() ); } @@ -77,7 +77,7 @@ fn explicit_value_name() { // Ensure the implicit `num_vals` is just 1 assert_eq!( Opt { my_special_arg: 10 }, - Opt::try_parse_from(&["test", "10"]).unwrap() + Opt::try_parse_from(["test", "10"]).unwrap() ); } @@ -89,10 +89,10 @@ fn option_type_is_optional() { } assert_eq!( Opt { arg: Some(42) }, - Opt::try_parse_from(&["test", "42"]).unwrap() + Opt::try_parse_from(["test", "42"]).unwrap() ); - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&["test"]).unwrap()); - assert!(Opt::try_parse_from(&["test", "42", "24"]).is_err()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from(["test"]).unwrap()); + assert!(Opt::try_parse_from(["test", "42", "24"]).is_err()); } #[test] @@ -103,15 +103,15 @@ fn vec_type_is_multiple_values() { } assert_eq!( Opt { arg: vec![24] }, - Opt::try_parse_from(&["test", "24"]).unwrap() + Opt::try_parse_from(["test", "24"]).unwrap() ); - assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { arg: vec![24, 42] }, - Opt::try_parse_from(&["test", "24", "42"]).unwrap() + Opt::try_parse_from(["test", "24", "42"]).unwrap() ); assert_eq!( clap::error::ErrorKind::ValueValidation, - Opt::try_parse_from(&["test", "NOPE"]).err().unwrap().kind() + Opt::try_parse_from(["test", "NOPE"]).err().unwrap().kind() ); } diff --git a/tests/derive/basic.rs b/tests/derive/basic.rs index a17f20b6211..8cb70dcbdbb 100644 --- a/tests/derive/basic.rs +++ b/tests/derive/basic.rs @@ -23,7 +23,7 @@ fn basic() { } assert_eq!( Opt { arg: 24 }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); } @@ -35,9 +35,9 @@ fn update_basic() { single_value: i32, } - let mut opt = Opt::try_parse_from(&["test", "-a0"]).unwrap(); + let mut opt = Opt::try_parse_from(["test", "-a0"]).unwrap(); - opt.update_from(&["test", "-a42"]); + opt.update_from(["test", "-a42"]); assert_eq!(Opt { single_value: 42 }, opt); } @@ -47,5 +47,5 @@ fn unit_struct() { #[derive(Parser, PartialEq, Debug)] struct Opt; - assert_eq!(Opt {}, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt {}, Opt::try_parse_from(["test"]).unwrap()); } diff --git a/tests/derive/boxed.rs b/tests/derive/boxed.rs index 5367d787012..d8b93809580 100644 --- a/tests/derive/boxed.rs +++ b/tests/derive/boxed.rs @@ -27,15 +27,15 @@ fn boxed_flatten_subcommand() { arg: Box::new(Ext { arg: 1 }) }) }, - Opt::try_parse_from(&["test", "flame", "1"]).unwrap() + Opt::try_parse_from(["test", "flame", "1"]).unwrap() ); } #[test] fn update_boxed_flatten_subcommand() { - let mut opt = Opt::try_parse_from(&["test", "flame", "1"]).unwrap(); + let mut opt = Opt::try_parse_from(["test", "flame", "1"]).unwrap(); - opt.update_from(&["test", "flame", "42"]); + opt.update_from(["test", "flame", "42"]); assert_eq!( Opt { diff --git a/tests/derive/custom_string_parsers.rs b/tests/derive/custom_string_parsers.rs index d4b087d7a25..3ab925c66ab 100644 --- a/tests/derive/custom_string_parsers.rs +++ b/tests/derive/custom_string_parsers.rs @@ -49,7 +49,7 @@ fn test_path_opt_simple() { option_path_1: None, option_path_2: Some(PathBuf::from("j.zip")), }, - PathOpt::try_parse_from(&[ + PathOpt::try_parse_from([ "test", "-p", "/usr/bin", "-v", "/a/b/c", "-v", "/d/e/f", "-v", "/g/h/i", "-q", "j.zip", ]) @@ -72,16 +72,16 @@ struct HexOpt { fn test_parse_hex() { assert_eq!( HexOpt { number: 5 }, - HexOpt::try_parse_from(&["test", "-n", "5"]).unwrap() + HexOpt::try_parse_from(["test", "-n", "5"]).unwrap() ); assert_eq!( HexOpt { number: 0x00ab_cdef }, - HexOpt::try_parse_from(&["test", "-n", "abcdef"]).unwrap() + HexOpt::try_parse_from(["test", "-n", "abcdef"]).unwrap() ); - let err = HexOpt::try_parse_from(&["test", "-n", "gg"]).unwrap_err(); + let err = HexOpt::try_parse_from(["test", "-n", "gg"]).unwrap_err(); assert!( err.to_string().contains("invalid digit found in string"), "{}", @@ -111,7 +111,7 @@ struct NoOpOpt { fn test_every_custom_parser() { assert_eq!( NoOpOpt { b: "B" }, - NoOpOpt::try_parse_from(&["test", "-b=?"]).unwrap() + NoOpOpt::try_parse_from(["test", "-b=?"]).unwrap() ); } @@ -119,7 +119,7 @@ fn test_every_custom_parser() { fn update_every_custom_parser() { let mut opt = NoOpOpt { b: "0" }; - opt.try_update_from(&["test", "-b=?"]).unwrap(); + opt.try_update_from(["test", "-b=?"]).unwrap(); assert_eq!(NoOpOpt { b: "B" }, opt); } @@ -140,6 +140,6 @@ fn test_parser_with_default_value() { integer: 9000, path: PathBuf::from("src/lib.rs"), }, - DefaultedOpt::try_parse_from(&["test", "-i", "9000", "-p", "src/lib.rs",]).unwrap() + DefaultedOpt::try_parse_from(["test", "-i", "9000", "-p", "src/lib.rs",]).unwrap() ); } diff --git a/tests/derive/default_value.rs b/tests/derive/default_value.rs index c1237c26056..532eb8f12ef 100644 --- a/tests/derive/default_value.rs +++ b/tests/derive/default_value.rs @@ -11,8 +11,8 @@ fn default_value() { #[arg(default_value = "3")] arg: i32, } - assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap()); - assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap()); + assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(["test"]).unwrap()); + assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(["test", "1"]).unwrap()); let help = utils::get_long_help::(); assert!(help.contains("[default: 3]")); @@ -25,8 +25,8 @@ fn default_value_t() { #[arg(default_value_t = 3)] arg: i32, } - assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap()); - assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap()); + assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(["test"]).unwrap()); + assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(["test", "1"]).unwrap()); let help = utils::get_long_help::(); assert!(help.contains("[default: 3]")); @@ -39,8 +39,8 @@ fn auto_default_value_t() { #[arg(default_value_t)] arg: i32, } - assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(&["test"]).unwrap()); - assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap()); + assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(["test"]).unwrap()); + assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(["test", "1"]).unwrap()); let help = utils::get_long_help::(); assert!(help.contains("[default: 0]")); @@ -53,7 +53,7 @@ fn default_values_t() { #[arg(default_values_t = vec![1, 2, 3])] arg1: Vec, - #[arg(long, default_values_t = &[4, 5, 6])] + #[arg(long, default_values_t = [4, 5, 6])] arg2: Vec, #[arg(long, default_values_t = [7, 8, 9])] @@ -77,7 +77,7 @@ fn default_values_t() { arg5: vec!["hello".to_string(), "world".to_string()], arg6: vec!["foo".to_string(), "bar".to_string()], }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { @@ -88,7 +88,7 @@ fn default_values_t() { arg5: vec!["hello".to_string(), "world".to_string()], arg6: vec!["foo".to_string(), "bar".to_string()], }, - Opt::try_parse_from(&["test", "1"]).unwrap() + Opt::try_parse_from(["test", "1"]).unwrap() ); assert_eq!( Opt { @@ -99,7 +99,7 @@ fn default_values_t() { arg5: vec!["baz".to_string()], arg6: vec!["foo".to_string(), "bar".to_string()], }, - Opt::try_parse_from(&["test", "--arg4", "42", "--arg4", "15", "--arg5", "baz"]).unwrap() + Opt::try_parse_from(["test", "--arg4", "42", "--arg4", "15", "--arg5", "baz"]).unwrap() ); let help = utils::get_long_help::(); @@ -117,13 +117,13 @@ fn default_value_os_t() { Opt { arg: PathBuf::from("abc.def") }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { arg: PathBuf::from("ghi") }, - Opt::try_parse_from(&["test", "ghi"]).unwrap() + Opt::try_parse_from(["test", "ghi"]).unwrap() ); let help = utils::get_long_help::(); @@ -141,7 +141,7 @@ fn default_values_os_t() { #[arg( long, - default_values_os_t = &[PathBuf::from("bar.baz")] + default_values_os_t = [PathBuf::from("bar.baz")] )] arg2: Vec, } @@ -150,14 +150,14 @@ fn default_values_os_t() { arg1: vec![PathBuf::from("abc.def"), PathBuf::from("123.foo")], arg2: vec![PathBuf::from("bar.baz")] }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { arg1: vec![PathBuf::from("ghi")], arg2: vec![PathBuf::from("baz.bar"), PathBuf::from("foo.bar")] }, - Opt::try_parse_from(&["test", "ghi", "--arg2", "baz.bar", "--arg2", "foo.bar"]).unwrap() + Opt::try_parse_from(["test", "ghi", "--arg2", "baz.bar", "--arg2", "foo.bar"]).unwrap() ); let help = utils::get_long_help::(); diff --git a/tests/derive/deny_warnings.rs b/tests/derive/deny_warnings.rs index d1b4345a31e..1b3fea2689f 100644 --- a/tests/derive/deny_warnings.rs +++ b/tests/derive/deny_warnings.rs @@ -31,7 +31,7 @@ fn warning_never_struct() { Opt { s: "foo".to_string() }, - Opt::try_parse_from(&["test", "foo"]).unwrap() + Opt::try_parse_from(["test", "foo"]).unwrap() ); } @@ -48,6 +48,6 @@ fn warning_never_enum() { Opt::Foo { s: "foo".to_string() }, - Opt::try_parse_from(&["test", "foo", "foo"]).unwrap() + Opt::try_parse_from(["test", "foo", "foo"]).unwrap() ); } diff --git a/tests/derive/explicit_name_no_renaming.rs b/tests/derive/explicit_name_no_renaming.rs index 6e0f79c2241..0a017dca28e 100644 --- a/tests/derive/explicit_name_no_renaming.rs +++ b/tests/derive/explicit_name_no_renaming.rs @@ -12,14 +12,14 @@ fn explicit_short_long_no_rename() { assert_eq!( Opt { foo: "long".into() }, - Opt::try_parse_from(&["test", "--.foo", "long"]).unwrap() + Opt::try_parse_from(["test", "--.foo", "long"]).unwrap() ); assert_eq!( Opt { foo: "short".into(), }, - Opt::try_parse_from(&["test", "-.", "short"]).unwrap() + Opt::try_parse_from(["test", "-.", "short"]).unwrap() ); } diff --git a/tests/derive/flags.rs b/tests/derive/flags.rs index 12eb7d51b71..75229899293 100644 --- a/tests/derive/flags.rs +++ b/tests/derive/flags.rs @@ -27,24 +27,21 @@ fn bool_type_is_flag() { alice: bool, } - assert_eq!( - Opt { alice: false }, - Opt::try_parse_from(&["test"]).unwrap() - ); + assert_eq!(Opt { alice: false }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { alice: true }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); assert_eq!( Opt { alice: true }, - Opt::try_parse_from(&["test", "-a", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a", "-a"]).unwrap() ); assert_eq!( Opt { alice: true }, - Opt::try_parse_from(&["test", "--alice"]).unwrap() + Opt::try_parse_from(["test", "--alice"]).unwrap() ); - assert!(Opt::try_parse_from(&["test", "-i"]).is_err()); - assert!(Opt::try_parse_from(&["test", "-a", "foo"]).is_err()); + assert!(Opt::try_parse_from(["test", "-i"]).is_err()); + assert!(Opt::try_parse_from(["test", "-a", "foo"]).is_err()); } #[test] @@ -65,19 +62,19 @@ fn non_bool_type_flag() { bob: usize, } - let opt = Opt::try_parse_from(&["test"]).unwrap(); + let opt = Opt::try_parse_from(["test"]).unwrap(); assert_eq!(opt.alice, 5); assert_eq!(opt.bob, 5); - let opt = Opt::try_parse_from(&["test", "-a"]).unwrap(); + let opt = Opt::try_parse_from(["test", "-a"]).unwrap(); assert_eq!(opt.alice, 10); assert_eq!(opt.bob, 5); - let opt = Opt::try_parse_from(&["test", "-b"]).unwrap(); + let opt = Opt::try_parse_from(["test", "-b"]).unwrap(); assert_eq!(opt.alice, 5); assert_eq!(opt.bob, 10); - let opt = Opt::try_parse_from(&["test", "-b", "-a"]).unwrap(); + let opt = Opt::try_parse_from(["test", "-b", "-a"]).unwrap(); assert_eq!(opt.alice, 10); assert_eq!(opt.bob, 10); } @@ -139,26 +136,26 @@ fn count() { assert_eq!( Opt { alice: 0, bob: 0 }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { alice: 1, bob: 0 }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); assert_eq!( Opt { alice: 2, bob: 0 }, - Opt::try_parse_from(&["test", "-a", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a", "-a"]).unwrap() ); assert_eq!( Opt { alice: 2, bob: 2 }, - Opt::try_parse_from(&["test", "-a", "--alice", "-bb"]).unwrap() + Opt::try_parse_from(["test", "-a", "--alice", "-bb"]).unwrap() ); assert_eq!( Opt { alice: 3, bob: 1 }, - Opt::try_parse_from(&["test", "-aaa", "--bob"]).unwrap() + Opt::try_parse_from(["test", "-aaa", "--bob"]).unwrap() ); - assert!(Opt::try_parse_from(&["test", "-i"]).is_err()); - assert!(Opt::try_parse_from(&["test", "-a", "foo"]).is_err()); + assert!(Opt::try_parse_from(["test", "-i"]).is_err()); + assert!(Opt::try_parse_from(["test", "-a", "foo"]).is_err()); } #[test] @@ -176,42 +173,42 @@ fn mixed_type_flags() { alice: false, bob: 0 }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { alice: true, bob: 0 }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); assert_eq!( Opt { alice: true, bob: 0 }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); assert_eq!( Opt { alice: false, bob: 1 }, - Opt::try_parse_from(&["test", "-b"]).unwrap() + Opt::try_parse_from(["test", "-b"]).unwrap() ); assert_eq!( Opt { alice: true, bob: 1 }, - Opt::try_parse_from(&["test", "--alice", "--bob"]).unwrap() + Opt::try_parse_from(["test", "--alice", "--bob"]).unwrap() ); assert_eq!( Opt { alice: true, bob: 4 }, - Opt::try_parse_from(&["test", "-bb", "-a", "-bb"]).unwrap() + Opt::try_parse_from(["test", "-bb", "-a", "-bb"]).unwrap() ); } @@ -240,7 +237,7 @@ fn ignore_qualified_bool_type() { Opt { arg: inner::bool("success".into()) }, - Opt::try_parse_from(&["test", "success"]).unwrap() + Opt::try_parse_from(["test", "success"]).unwrap() ); } @@ -254,12 +251,12 @@ fn override_implicit_action() { assert_eq!( Opt { arg: false }, - Opt::try_parse_from(&["test", "--arg", "false"]).unwrap() + Opt::try_parse_from(["test", "--arg", "false"]).unwrap() ); assert_eq!( Opt { arg: true }, - Opt::try_parse_from(&["test", "--arg", "true"]).unwrap() + Opt::try_parse_from(["test", "--arg", "true"]).unwrap() ); } @@ -273,12 +270,12 @@ fn override_implicit_from_flag_positional() { assert_eq!( Opt { arg: false }, - Opt::try_parse_from(&["test", "false"]).unwrap() + Opt::try_parse_from(["test", "false"]).unwrap() ); assert_eq!( Opt { arg: true }, - Opt::try_parse_from(&["test", "true"]).unwrap() + Opt::try_parse_from(["test", "true"]).unwrap() ); } @@ -297,7 +294,7 @@ fn unit_for_negation() { arg: false, no_arg: () }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( @@ -305,7 +302,7 @@ fn unit_for_negation() { arg: true, no_arg: () }, - Opt::try_parse_from(&["test", "--arg"]).unwrap() + Opt::try_parse_from(["test", "--arg"]).unwrap() ); assert_eq!( @@ -313,7 +310,7 @@ fn unit_for_negation() { arg: false, no_arg: () }, - Opt::try_parse_from(&["test", "--no-arg"]).unwrap() + Opt::try_parse_from(["test", "--no-arg"]).unwrap() ); assert_eq!( @@ -321,7 +318,7 @@ fn unit_for_negation() { arg: true, no_arg: () }, - Opt::try_parse_from(&["test", "--no-arg", "--arg"]).unwrap() + Opt::try_parse_from(["test", "--no-arg", "--arg"]).unwrap() ); assert_eq!( @@ -329,6 +326,6 @@ fn unit_for_negation() { arg: false, no_arg: () }, - Opt::try_parse_from(&["test", "--arg", "--no-arg"]).unwrap() + Opt::try_parse_from(["test", "--arg", "--no-arg"]).unwrap() ); } diff --git a/tests/derive/flatten.rs b/tests/derive/flatten.rs index 7ef6ad86cd8..86468eb5592 100644 --- a/tests/derive/flatten.rs +++ b/tests/derive/flatten.rs @@ -32,10 +32,10 @@ fn flatten() { Opt { common: Common { arg: 42 } }, - Opt::try_parse_from(&["test", "42"]).unwrap() + Opt::try_parse_from(["test", "42"]).unwrap() ); - assert!(Opt::try_parse_from(&["test"]).is_err()); - assert!(Opt::try_parse_from(&["test", "42", "24"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); + assert!(Opt::try_parse_from(["test", "42", "24"]).is_err()); } #[cfg(debug_assertions)] @@ -55,7 +55,7 @@ fn flatten_twice() { #[command(flatten)] c2: Common, } - Opt::try_parse_from(&["test", "42", "43"]).unwrap(); + Opt::try_parse_from(["test", "42", "43"]).unwrap(); } #[test] @@ -90,14 +90,14 @@ fn flatten_in_subcommand() { all: false, common: Common { arg: 42 } }, - Opt::try_parse_from(&["test", "fetch", "42"]).unwrap() + Opt::try_parse_from(["test", "fetch", "42"]).unwrap() ); assert_eq!( Opt::Add(Add { interactive: true, common: Common { arg: 43 } }), - Opt::try_parse_from(&["test", "add", "-i", "43"]).unwrap() + Opt::try_parse_from(["test", "add", "-i", "43"]).unwrap() ); } @@ -117,14 +117,14 @@ fn update_args_with_flatten() { let mut opt = Opt { common: Common { arg: 42 }, }; - opt.try_update_from(&["test"]).unwrap(); - assert_eq!(Opt::try_parse_from(&["test", "42"]).unwrap(), opt); + opt.try_update_from(["test"]).unwrap(); + assert_eq!(Opt::try_parse_from(["test", "42"]).unwrap(), opt); let mut opt = Opt { common: Common { arg: 42 }, }; - opt.try_update_from(&["test", "52"]).unwrap(); - assert_eq!(Opt::try_parse_from(&["test", "52"]).unwrap(), opt); + opt.try_update_from(["test", "52"]).unwrap(); + assert_eq!(Opt::try_parse_from(["test", "52"]).unwrap(), opt); } #[derive(Subcommand, PartialEq, Debug)] @@ -155,35 +155,35 @@ enum Opt { fn merge_subcommands_with_flatten() { assert_eq!( Opt::BaseCli(BaseCli::Command1(Command1 { arg1: 42, arg2: 44 })), - Opt::try_parse_from(&["test", "command1", "42", "44"]).unwrap() + Opt::try_parse_from(["test", "command1", "42", "44"]).unwrap() ); assert_eq!( Opt::Command2(Command2 { arg2: 43 }), - Opt::try_parse_from(&["test", "command2", "43"]).unwrap() + Opt::try_parse_from(["test", "command2", "43"]).unwrap() ); } #[test] fn update_subcommands_with_flatten() { let mut opt = Opt::BaseCli(BaseCli::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "command1", "42", "44"]) + opt.try_update_from(["test", "command1", "42", "44"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command1", "42", "44"]).unwrap(), + Opt::try_parse_from(["test", "command1", "42", "44"]).unwrap(), opt ); let mut opt = Opt::BaseCli(BaseCli::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "command1", "42"]).unwrap(); + opt.try_update_from(["test", "command1", "42"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command1", "42", "14"]).unwrap(), + Opt::try_parse_from(["test", "command1", "42", "14"]).unwrap(), opt ); let mut opt = Opt::BaseCli(BaseCli::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "command2", "43"]).unwrap(); + opt.try_update_from(["test", "command2", "43"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command2", "43"]).unwrap(), + Opt::try_parse_from(["test", "command2", "43"]).unwrap(), opt ); } @@ -207,7 +207,7 @@ fn flatten_with_doc_comment() { Opt { common: Common { arg: 42 } }, - Opt::try_parse_from(&["test", "42"]).unwrap() + Opt::try_parse_from(["test", "42"]).unwrap() ); let help = utils::get_help::(); @@ -273,10 +273,7 @@ fn optional_flatten() { git: Option, } - assert_eq!( - Opt { source: None }, - Opt::try_parse_from(&["test"]).unwrap() - ); + assert_eq!(Opt { source: None }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { source: Some(Source { @@ -285,7 +282,7 @@ fn optional_flatten() { git: None, }), }, - Opt::try_parse_from(&["test", "serde"]).unwrap() + Opt::try_parse_from(["test", "serde"]).unwrap() ); assert_eq!( Opt { @@ -295,6 +292,6 @@ fn optional_flatten() { git: None, }), }, - Opt::try_parse_from(&["test", "--path=./"]).unwrap() + Opt::try_parse_from(["test", "--path=./"]).unwrap() ); } diff --git a/tests/derive/generic.rs b/tests/derive/generic.rs index 54b50a074a2..0775bd5480e 100644 --- a/tests/derive/generic.rs +++ b/tests/derive/generic.rs @@ -17,7 +17,7 @@ fn generic_struct_flatten() { Outer { inner: Inner { answer: 42 } }, - Outer::parse_from(&["--answer", "42"]) + Outer::parse_from(["--answer", "42"]) ) } @@ -41,7 +41,7 @@ fn generic_struct_flatten_w_where_clause() { Outer { inner: Inner { answer: 42 } }, - Outer::parse_from(&["--answer", "42"]) + Outer::parse_from(["--answer", "42"]) ) } @@ -60,7 +60,7 @@ fn generic_enum() { assert_eq!( GenericEnum::Start(Inner { answer: 42 }), - GenericEnum::parse_from(&["test", "start", "42"]) + GenericEnum::parse_from(["test", "start", "42"]) ) } @@ -82,7 +82,7 @@ fn generic_enum_w_where_clause() { assert_eq!( GenericEnum::Start(Inner { answer: 42 }), - GenericEnum::parse_from(&["test", "start", "42"]) + GenericEnum::parse_from(["test", "start", "42"]) ) } @@ -101,7 +101,7 @@ fn generic_w_fromstr_trait_bound() { assert_eq!( Opt:: { answer: 42 }, - Opt::::parse_from(&["--answer", "42"]) + Opt::::parse_from(["--answer", "42"]) ) } @@ -121,7 +121,7 @@ fn generic_wo_trait_bound() { answer: 42, took: None }, - Opt::::parse_from(&["--answer", "42"]) + Opt::::parse_from(["--answer", "42"]) ) } @@ -140,6 +140,6 @@ fn generic_where_clause_w_trailing_comma() { assert_eq!( Opt:: { answer: 42 }, - Opt::::parse_from(&["--answer", "42"]) + Opt::::parse_from(["--answer", "42"]) ) } diff --git a/tests/derive/groups.rs b/tests/derive/groups.rs index 6b6129386d0..8096ca0e15d 100644 --- a/tests/derive/groups.rs +++ b/tests/derive/groups.rs @@ -20,7 +20,7 @@ fn test_safely_nest_parser() { Opt { foo: Foo { foo: true } }, - Opt::try_parse_from(&["test", "--foo"]).unwrap() + Opt::try_parse_from(["test", "--foo"]).unwrap() ); } diff --git a/tests/derive/help.rs b/tests/derive/help.rs index 76d5ab6ed79..61e45b4c182 100644 --- a/tests/derive/help.rs +++ b/tests/derive/help.rs @@ -211,7 +211,7 @@ fn derive_generated_error_has_full_context() { }, } - let result = Opts::try_parse_from(&["test", "sub"]); + let result = Opts::try_parse_from(["test", "sub"]); assert!( result.is_err(), "`SubcommandsNegateReqs` with non-optional `req_str` should fail: {:?}", diff --git a/tests/derive/issues.rs b/tests/derive/issues.rs index fd1f3a292b2..73790f113ce 100644 --- a/tests/derive/issues.rs +++ b/tests/derive/issues.rs @@ -21,11 +21,11 @@ fn issue_151_groups_within_subcommands() { a: Opt, } - assert!(Cli::try_parse_from(&["test"]).is_err()); - assert!(Cli::try_parse_from(&["test", "--foo=v1"]).is_ok()); - assert!(Cli::try_parse_from(&["test", "--bar=v2"]).is_ok()); - assert!(Cli::try_parse_from(&["test", "--zebra=v3"]).is_err()); - assert!(Cli::try_parse_from(&["test", "--foo=v1", "--bar=v2"]).is_ok()); + assert!(Cli::try_parse_from(["test"]).is_err()); + assert!(Cli::try_parse_from(["test", "--foo=v1"]).is_ok()); + assert!(Cli::try_parse_from(["test", "--bar=v2"]).is_ok()); + assert!(Cli::try_parse_from(["test", "--zebra=v3"]).is_err()); + assert!(Cli::try_parse_from(["test", "--foo=v1", "--bar=v2"]).is_ok()); } #[test] @@ -46,10 +46,10 @@ fn issue_289() { TestCommand, } - assert!(Args::try_parse_from(&["test", "some-command", "test-command"]).is_ok()); - assert!(Args::try_parse_from(&["test", "some", "test-command"]).is_ok()); - assert!(Args::try_parse_from(&["test", "some-command", "test"]).is_ok()); - assert!(Args::try_parse_from(&["test", "some", "test"]).is_ok()); + assert!(Args::try_parse_from(["test", "some-command", "test-command"]).is_ok()); + assert!(Args::try_parse_from(["test", "some", "test-command"]).is_ok()); + assert!(Args::try_parse_from(["test", "some-command", "test"]).is_ok()); + assert!(Args::try_parse_from(["test", "some", "test"]).is_ok()); } #[test] diff --git a/tests/derive/naming.rs b/tests/derive/naming.rs index 9afad2abfd2..441ca948d91 100644 --- a/tests/derive/naming.rs +++ b/tests/derive/naming.rs @@ -12,7 +12,7 @@ fn test_standalone_long_generates_kebab_case() { assert_eq!( Opt { FOO_OPTION: true }, - Opt::try_parse_from(&["test", "--foo-option"]).unwrap() + Opt::try_parse_from(["test", "--foo-option"]).unwrap() ); } @@ -26,7 +26,7 @@ fn test_custom_long_overwrites_default_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foo"]).unwrap() + Opt::try_parse_from(["test", "--foo"]).unwrap() ); } @@ -40,7 +40,7 @@ fn test_standalone_long_uses_previous_defined_custom_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foo"]).unwrap() + Opt::try_parse_from(["test", "--foo"]).unwrap() ); } @@ -54,7 +54,7 @@ fn test_standalone_long_ignores_afterwards_defined_custom_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foo-option"]).unwrap() + Opt::try_parse_from(["test", "--foo-option"]).unwrap() ); } @@ -68,7 +68,7 @@ fn test_standalone_long_uses_previous_defined_custom_id() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foo"]).unwrap() + Opt::try_parse_from(["test", "--foo"]).unwrap() ); } @@ -82,7 +82,7 @@ fn test_standalone_long_ignores_afterwards_defined_custom_id() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foo-option"]).unwrap() + Opt::try_parse_from(["test", "--foo-option"]).unwrap() ); } @@ -97,7 +97,7 @@ fn test_standalone_short_generates_kebab_case() { assert_eq!( Opt { FOO_OPTION: true }, - Opt::try_parse_from(&["test", "-f"]).unwrap() + Opt::try_parse_from(["test", "-f"]).unwrap() ); } @@ -111,7 +111,7 @@ fn test_custom_short_overwrites_default_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-o"]).unwrap() + Opt::try_parse_from(["test", "-o"]).unwrap() ); } @@ -125,7 +125,7 @@ fn test_standalone_short_uses_previous_defined_custom_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-o"]).unwrap() + Opt::try_parse_from(["test", "-o"]).unwrap() ); } @@ -139,7 +139,7 @@ fn test_standalone_short_ignores_afterwards_defined_custom_name() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-f"]).unwrap() + Opt::try_parse_from(["test", "-f"]).unwrap() ); } @@ -153,7 +153,7 @@ fn test_standalone_short_uses_previous_defined_custom_id() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-o"]).unwrap() + Opt::try_parse_from(["test", "-o"]).unwrap() ); } @@ -167,7 +167,7 @@ fn test_standalone_short_ignores_afterwards_defined_custom_id() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-f"]).unwrap() + Opt::try_parse_from(["test", "-f"]).unwrap() ); } @@ -181,7 +181,7 @@ fn test_standalone_long_uses_previous_defined_casing() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--FOO_OPTION"]).unwrap() + Opt::try_parse_from(["test", "--FOO_OPTION"]).unwrap() ); } @@ -195,7 +195,7 @@ fn test_standalone_short_uses_previous_defined_casing() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "-F"]).unwrap() + Opt::try_parse_from(["test", "-F"]).unwrap() ); } @@ -210,7 +210,7 @@ fn test_standalone_long_works_with_verbatim_casing() { assert_eq!( Opt { _fOO_oPtiON: true }, - Opt::try_parse_from(&["test", "--_fOO_oPtiON"]).unwrap() + Opt::try_parse_from(["test", "--_fOO_oPtiON"]).unwrap() ); } @@ -224,7 +224,7 @@ fn test_standalone_short_works_with_verbatim_casing() { assert_eq!( Opt { _foo: true }, - Opt::try_parse_from(&["test", "-_"]).unwrap() + Opt::try_parse_from(["test", "-_"]).unwrap() ); } @@ -239,7 +239,7 @@ fn test_rename_all_is_propagated_from_struct_to_fields() { assert_eq!( Opt { foo: true }, - Opt::try_parse_from(&["test", "--FOO"]).unwrap() + Opt::try_parse_from(["test", "--FOO"]).unwrap() ); } @@ -262,7 +262,7 @@ fn test_rename_all_is_not_propagated_from_struct_into_flattened() { Opt { foo: Foo { foo: true } }, - Opt::try_parse_from(&["test", "--foo"]).unwrap() + Opt::try_parse_from(["test", "--foo"]).unwrap() ); } @@ -276,7 +276,7 @@ fn test_lower_is_renamed() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--foooption"]).unwrap() + Opt::try_parse_from(["test", "--foooption"]).unwrap() ); } @@ -290,7 +290,7 @@ fn test_upper_is_renamed() { assert_eq!( Opt { foo_option: true }, - Opt::try_parse_from(&["test", "--FOOOPTION"]).unwrap() + Opt::try_parse_from(["test", "--FOOOPTION"]).unwrap() ); } @@ -303,7 +303,7 @@ fn test_single_word_enum_variant_is_default_renamed_into_kebab_case() { assert_eq!( Opt::Command { foo: 0 }, - Opt::try_parse_from(&["test", "command", "0"]).unwrap() + Opt::try_parse_from(["test", "command", "0"]).unwrap() ); } @@ -316,7 +316,7 @@ fn test_multi_word_enum_variant_is_renamed() { assert_eq!( Opt::FirstCommand { foo: 0 }, - Opt::try_parse_from(&["test", "first-command", "0"]).unwrap() + Opt::try_parse_from(["test", "first-command", "0"]).unwrap() ); } @@ -341,7 +341,7 @@ fn test_rename_all_is_not_propagated_from_struct_into_subcommand() { Opt { foo: Foo::Command { foo: true } }, - Opt::try_parse_from(&["test", "command", "--foo"]).unwrap() + Opt::try_parse_from(["test", "command", "--foo"]).unwrap() ); } @@ -359,7 +359,7 @@ fn test_rename_all_is_propagated_from_enum_to_variants() { assert_eq!( Opt::FirstVariant, - Opt::try_parse_from(&["test", "FIRST_VARIANT"]).unwrap() + Opt::try_parse_from(["test", "FIRST_VARIANT"]).unwrap() ); } @@ -379,7 +379,7 @@ fn test_rename_all_is_propagated_from_enum_to_variant_fields() { Opt::SecondVariant { foo: "value".into() }, - Opt::try_parse_from(&["test", "SECOND_VARIANT", "--FOO", "value"]).unwrap() + Opt::try_parse_from(["test", "SECOND_VARIANT", "--FOO", "value"]).unwrap() ); } @@ -401,11 +401,11 @@ fn test_rename_all_is_propagation_can_be_overridden() { assert_eq!( Opt::FirstVariant { foo_option: true }, - Opt::try_parse_from(&["test", "first-variant", "--foo-option"]).unwrap() + Opt::try_parse_from(["test", "first-variant", "--foo-option"]).unwrap() ); assert_eq!( Opt::SecondVariant { foo_option: true }, - Opt::try_parse_from(&["test", "SECOND_VARIANT", "--foo-option"]).unwrap() + Opt::try_parse_from(["test", "SECOND_VARIANT", "--foo-option"]).unwrap() ); } diff --git a/tests/derive/nested_subcommands.rs b/tests/derive/nested_subcommands.rs index e8fa2977a92..e610f05fe8f 100644 --- a/tests/derive/nested_subcommands.rs +++ b/tests/derive/nested_subcommands.rs @@ -42,7 +42,7 @@ struct Opt2 { #[test] fn test_no_cmd() { - let result = Opt::try_parse_from(&["test"]); + let result = Opt::try_parse_from(["test"]); assert!(result.is_err()); assert_eq!( @@ -51,7 +51,7 @@ fn test_no_cmd() { verbose: 0, cmd: None }, - Opt2::try_parse_from(&["test"]).unwrap() + Opt2::try_parse_from(["test"]).unwrap() ); } @@ -63,7 +63,7 @@ fn test_fetch() { verbose: 3, cmd: Sub::Fetch {} }, - Opt::try_parse_from(&["test", "-vvv", "fetch"]).unwrap() + Opt::try_parse_from(["test", "-vvv", "fetch"]).unwrap() ); assert_eq!( Opt { @@ -71,7 +71,7 @@ fn test_fetch() { verbose: 0, cmd: Sub::Fetch {} }, - Opt::try_parse_from(&["test", "--force", "fetch"]).unwrap() + Opt::try_parse_from(["test", "--force", "fetch"]).unwrap() ); } @@ -83,7 +83,7 @@ fn test_add() { verbose: 0, cmd: Sub::Add {} }, - Opt::try_parse_from(&["test", "add"]).unwrap() + Opt::try_parse_from(["test", "add"]).unwrap() ); assert_eq!( Opt { @@ -91,19 +91,19 @@ fn test_add() { verbose: 2, cmd: Sub::Add {} }, - Opt::try_parse_from(&["test", "-vv", "add"]).unwrap() + Opt::try_parse_from(["test", "-vv", "add"]).unwrap() ); } #[test] fn test_badinput() { - let result = Opt::try_parse_from(&["test", "badcmd"]); + let result = Opt::try_parse_from(["test", "badcmd"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "add", "--verbose"]); + let result = Opt::try_parse_from(["test", "add", "--verbose"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "--badopt", "add"]); + let result = Opt::try_parse_from(["test", "--badopt", "add"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "add", "--badopt"]); + let result = Opt::try_parse_from(["test", "add", "--badopt"]); assert!(result.is_err()); } @@ -141,7 +141,7 @@ fn test_subsubcommand() { cmd: Sub3::Quux {} } }, - Opt3::try_parse_from(&["test", "--all", "foo", "lib.rs", "quux"]).unwrap() + Opt3::try_parse_from(["test", "--all", "foo", "lib.rs", "quux"]).unwrap() ); } diff --git a/tests/derive/non_literal_attributes.rs b/tests/derive/non_literal_attributes.rs index bc2df92b46a..63a1d0254c4 100644 --- a/tests/derive/non_literal_attributes.rs +++ b/tests/derive/non_literal_attributes.rs @@ -50,7 +50,7 @@ fn test_slice() { files: Vec::new(), values: vec![], }, - Opt::try_parse_from(&["test", "-l", "1"]).unwrap() + Opt::try_parse_from(["test", "-l", "1"]).unwrap() ); assert_eq!( Opt { @@ -59,7 +59,7 @@ fn test_slice() { files: Vec::new(), values: vec![], }, - Opt::try_parse_from(&["test", "--level", "1"]).unwrap() + Opt::try_parse_from(["test", "--level", "1"]).unwrap() ); assert_eq!( Opt { @@ -68,7 +68,7 @@ fn test_slice() { files: Vec::new(), values: vec![], }, - Opt::try_parse_from(&["test", "--set-level", "1"]).unwrap() + Opt::try_parse_from(["test", "--set-level", "1"]).unwrap() ); assert_eq!( Opt { @@ -77,7 +77,7 @@ fn test_slice() { files: Vec::new(), values: vec![], }, - Opt::try_parse_from(&["test", "--lvl", "1"]).unwrap() + Opt::try_parse_from(["test", "--lvl", "1"]).unwrap() ); } @@ -90,7 +90,7 @@ fn test_multi_args() { files: vec!["file".to_string()], values: vec![], }, - Opt::try_parse_from(&["test", "-l", "1", "file"]).unwrap() + Opt::try_parse_from(["test", "-l", "1", "file"]).unwrap() ); assert_eq!( Opt { @@ -99,13 +99,13 @@ fn test_multi_args() { files: vec!["FILE".to_string()], values: vec![1], }, - Opt::try_parse_from(&["test", "-l", "1", "--values", "1", "--", "FILE"]).unwrap() + Opt::try_parse_from(["test", "-l", "1", "--values", "1", "--", "FILE"]).unwrap() ); } #[test] fn test_multi_args_fail() { - let result = Opt::try_parse_from(&["test", "-l", "1", "--", "FILE"]); + let result = Opt::try_parse_from(["test", "-l", "1", "--", "FILE"]); assert!(result.is_err()); } @@ -118,9 +118,9 @@ fn test_bool() { files: vec![], values: vec![], }, - Opt::try_parse_from(&["test", "-l", "1", "--x=1"]).unwrap() + Opt::try_parse_from(["test", "-l", "1", "--x=1"]).unwrap() ); - let result = Opt::try_parse_from(&["test", "-l", "1", "--x", "1"]); + let result = Opt::try_parse_from(["test", "-l", "1", "--x", "1"]); assert!(result.is_err()); assert_eq!(result.unwrap_err().kind(), ErrorKind::NoEquals); } @@ -140,16 +140,16 @@ struct HexOpt { fn test_parse_hex_function_path() { assert_eq!( HexOpt { number: 5 }, - HexOpt::try_parse_from(&["test", "-n", "5"]).unwrap() + HexOpt::try_parse_from(["test", "-n", "5"]).unwrap() ); assert_eq!( HexOpt { number: 0x00ab_cdef }, - HexOpt::try_parse_from(&["test", "-n", "abcdef"]).unwrap() + HexOpt::try_parse_from(["test", "-n", "abcdef"]).unwrap() ); - let err = HexOpt::try_parse_from(&["test", "-n", "gg"]).unwrap_err(); + let err = HexOpt::try_parse_from(["test", "-n", "gg"]).unwrap_err(); assert!( err.to_string().contains("invalid digit found in string"), "{}", diff --git a/tests/derive/options.rs b/tests/derive/options.rs index d6420ab977b..be17f391573 100644 --- a/tests/derive/options.rs +++ b/tests/derive/options.rs @@ -28,21 +28,21 @@ fn required_option() { } assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "-a42"]).unwrap() + Opt::try_parse_from(["test", "-a42"]).unwrap() ); assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "42"]).unwrap() ); assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "--arg", "42"]).unwrap() + Opt::try_parse_from(["test", "--arg", "42"]).unwrap() ); assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "--arg", "24", "--arg", "42"]).unwrap() + Opt::try_parse_from(["test", "--arg", "24", "--arg", "42"]).unwrap() ); - assert!(Opt::try_parse_from(&["test"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); } #[test] @@ -55,13 +55,13 @@ fn option_with_default() { } assert_eq!( Opt { arg: 24 }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); - assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -74,13 +74,13 @@ fn option_with_raw_default() { } assert_eq!( Opt { arg: 24 }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); - assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: 42 }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -102,10 +102,10 @@ fn option_from_str() { a: Option, } - assert_eq!(Opt { a: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { a: None }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { a: Some(A) }, - Opt::try_parse_from(&["test", "foo"]).unwrap() + Opt::try_parse_from(["test", "foo"]).unwrap() ); } @@ -130,11 +130,11 @@ fn vec_from_str() { assert_eq!( Opt { a: Vec::new() }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); assert_eq!( Opt { a: vec![A] }, - Opt::try_parse_from(&["test", "foo"]).unwrap() + Opt::try_parse_from(["test", "foo"]).unwrap() ); } @@ -158,10 +158,10 @@ fn option_vec_from_str() { a: Option>, } - assert_eq!(Opt { a: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { a: None }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { a: Some(vec![A]) }, - Opt::try_parse_from(&["test", "-a", "foo"]).unwrap() + Opt::try_parse_from(["test", "-a", "foo"]).unwrap() ); } @@ -175,13 +175,13 @@ fn option_type_is_optional() { } assert_eq!( Opt { arg: Some(42) }, - Opt::try_parse_from(&["test", "-a42"]).unwrap() + Opt::try_parse_from(["test", "-a42"]).unwrap() ); assert_eq!( Opt { arg: Some(42) }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -210,7 +210,7 @@ fn required_with_option_type() { req_str: Some(("arg").into()), cmd: None, }, - Opt::try_parse_from(&["test", "arg"]).unwrap() + Opt::try_parse_from(["test", "arg"]).unwrap() ); assert_eq!( @@ -218,10 +218,10 @@ fn required_with_option_type() { req_str: None, cmd: Some(SubCommands::ExSub { verbose: 1 }), }, - Opt::try_parse_from(&["test", "ex-sub", "-v"]).unwrap() + Opt::try_parse_from(["test", "ex-sub", "-v"]).unwrap() ); - assert!(Opt::try_parse_from(&["test"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); } #[test] @@ -241,7 +241,7 @@ fn ignore_qualified_option_type() { Opt { arg: Some("success".into()) }, - Opt::try_parse_from(&["test", "success"]).unwrap() + Opt::try_parse_from(["test", "success"]).unwrap() ); } @@ -258,19 +258,19 @@ fn option_option_type_is_optional_value() { Opt { arg: Some(Some(42)) }, - Opt::try_parse_from(&["test", "-a42"]).unwrap() + Opt::try_parse_from(["test", "-a42"]).unwrap() ); assert_eq!( Opt { arg: Some(None) }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); assert_eq!( Opt { arg: Some(Some(42)) }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -302,42 +302,42 @@ fn two_option_option_types() { arg: Some(Some(42)), field: Some(Some("f".into())) }, - Opt::try_parse_from(&["test", "-a42", "--field", "f"]).unwrap() + Opt::try_parse_from(["test", "-a42", "--field", "f"]).unwrap() ); assert_eq!( Opt { arg: Some(Some(42)), field: Some(None) }, - Opt::try_parse_from(&["test", "-a42", "--field"]).unwrap() + Opt::try_parse_from(["test", "-a42", "--field"]).unwrap() ); assert_eq!( Opt { arg: Some(None), field: Some(None) }, - Opt::try_parse_from(&["test", "-a", "--field"]).unwrap() + Opt::try_parse_from(["test", "-a", "--field"]).unwrap() ); assert_eq!( Opt { arg: Some(None), field: Some(Some("f".into())) }, - Opt::try_parse_from(&["test", "-a", "--field", "f"]).unwrap() + Opt::try_parse_from(["test", "-a", "--field", "f"]).unwrap() ); assert_eq!( Opt { arg: None, field: Some(None) }, - Opt::try_parse_from(&["test", "--field"]).unwrap() + Opt::try_parse_from(["test", "--field"]).unwrap() ); assert_eq!( Opt { arg: None, field: None }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); } @@ -351,12 +351,12 @@ fn vec_type_is_multiple_occurrences() { } assert_eq!( Opt { arg: vec![24] }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); - assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { arg: vec![24, 42] }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); } @@ -370,12 +370,12 @@ fn vec_type_with_required() { } assert_eq!( Opt { arg: vec![24] }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); - assert!(Opt::try_parse_from(&["test"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); assert_eq!( Opt { arg: vec![24, 42] }, - Opt::try_parse_from(&["test", "-a", "24", "-a", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "-a", "42"]).unwrap() ); } @@ -389,12 +389,12 @@ fn vec_type_with_multiple_values_only() { } assert_eq!( Opt { arg: vec![24] }, - Opt::try_parse_from(&["test", "-a24"]).unwrap() + Opt::try_parse_from(["test", "-a24"]).unwrap() ); - assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(["test"]).unwrap()); assert_eq!( Opt { arg: vec![24, 42] }, - Opt::try_parse_from(&["test", "-a", "24", "42"]).unwrap() + Opt::try_parse_from(["test", "-a", "24", "42"]).unwrap() ); } @@ -415,7 +415,7 @@ fn ignore_qualified_vec_type() { Opt { arg: vec!["success".into()] }, - Opt::try_parse_from(&["test", "success"]).unwrap() + Opt::try_parse_from(["test", "success"]).unwrap() ); } @@ -429,17 +429,17 @@ fn option_vec_type() { } assert_eq!( Opt { arg: Some(vec![1]) }, - Opt::try_parse_from(&["test", "-a", "1"]).unwrap() + Opt::try_parse_from(["test", "-a", "1"]).unwrap() ); assert_eq!( Opt { arg: Some(vec![1, 2]) }, - Opt::try_parse_from(&["test", "-a", "1", "-a", "2"]).unwrap() + Opt::try_parse_from(["test", "-a", "1", "-a", "2"]).unwrap() ); - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -452,22 +452,22 @@ fn option_vec_type_structopt_behavior() { } assert_eq!( Opt { arg: Some(vec![1]) }, - Opt::try_parse_from(&["test", "-a", "1"]).unwrap() + Opt::try_parse_from(["test", "-a", "1"]).unwrap() ); assert_eq!( Opt { arg: Some(vec![1, 2]) }, - Opt::try_parse_from(&["test", "-a", "1", "2"]).unwrap() + Opt::try_parse_from(["test", "-a", "1", "2"]).unwrap() ); assert_eq!( Opt { arg: Some(vec![]) }, - Opt::try_parse_from(&["test", "-a"]).unwrap() + Opt::try_parse_from(["test", "-a"]).unwrap() ); - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&["test"]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from(["test"]).unwrap()); } #[test] @@ -487,7 +487,7 @@ fn two_option_vec_types() { arg: Some(vec![1]), b: None, }, - Opt::try_parse_from(&["test", "-a", "1"]).unwrap() + Opt::try_parse_from(["test", "-a", "1"]).unwrap() ); assert_eq!( @@ -495,7 +495,7 @@ fn two_option_vec_types() { arg: Some(vec![1]), b: Some(vec![1]) }, - Opt::try_parse_from(&["test", "-a", "1", "-b", "1"]).unwrap() + Opt::try_parse_from(["test", "-a", "1", "-b", "1"]).unwrap() ); assert_eq!( @@ -503,12 +503,12 @@ fn two_option_vec_types() { arg: Some(vec![1, 2]), b: Some(vec![1, 2]) }, - Opt::try_parse_from(&["test", "-a", "1", "-a", "2", "-b", "1", "-b", "2"]).unwrap() + Opt::try_parse_from(["test", "-a", "1", "-a", "2", "-b", "1", "-b", "2"]).unwrap() ); assert_eq!( Opt { arg: None, b: None }, - Opt::try_parse_from(&["test"]).unwrap() + Opt::try_parse_from(["test"]).unwrap() ); } @@ -522,7 +522,7 @@ fn explicit_value_parser() { } assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "--arg", "42"]).unwrap() + Opt::try_parse_from(["test", "--arg", "42"]).unwrap() ); } @@ -536,6 +536,6 @@ fn implicit_value_parser() { } assert_eq!( Opt { arg: 42 }, - Opt::try_parse_from(&["test", "--arg", "42"]).unwrap() + Opt::try_parse_from(["test", "--arg", "42"]).unwrap() ); } diff --git a/tests/derive/raw_bool_literal.rs b/tests/derive/raw_bool_literal.rs index f642a13a0be..835bdd749c9 100644 --- a/tests/derive/raw_bool_literal.rs +++ b/tests/derive/raw_bool_literal.rs @@ -24,6 +24,6 @@ fn raw_bool_literal() { a: "one".into(), b: "--help".into() }, - Opt::try_parse_from(&["test", "one", "--", "--help"]).unwrap() + Opt::try_parse_from(["test", "one", "--", "--help"]).unwrap() ); } diff --git a/tests/derive/raw_idents.rs b/tests/derive/raw_idents.rs index 7dfc2d45258..30a8a994674 100644 --- a/tests/derive/raw_idents.rs +++ b/tests/derive/raw_idents.rs @@ -12,13 +12,13 @@ fn raw_idents() { Opt { r#type: "long".into() }, - Opt::try_parse_from(&["test", "--type", "long"]).unwrap() + Opt::try_parse_from(["test", "--type", "long"]).unwrap() ); assert_eq!( Opt { r#type: "short".into() }, - Opt::try_parse_from(&["test", "-t", "short"]).unwrap() + Opt::try_parse_from(["test", "-t", "short"]).unwrap() ); } diff --git a/tests/derive/skip.rs b/tests/derive/skip.rs index c2bcfbd00a7..b6924fb132f 100644 --- a/tests/derive/skip.rs +++ b/tests/derive/skip.rs @@ -18,9 +18,9 @@ fn skip_1() { s: u32, } - assert!(Opt::try_parse_from(&["test", "-x", "10", "20"]).is_err()); + assert!(Opt::try_parse_from(["test", "-x", "10", "20"]).is_err()); - let mut opt = Opt::try_parse_from(&["test", "-x", "10"]).unwrap(); + let mut opt = Opt::try_parse_from(["test", "-x", "10"]).unwrap(); assert_eq!( opt, Opt { @@ -30,7 +30,7 @@ fn skip_1() { ); opt.s = 42; - opt.update_from(&["test", "-x", "22"]); + opt.update_from(["test", "-x", "22"]); assert_eq!(opt, Opt { x: 22, s: 42 }); } @@ -54,7 +54,7 @@ fn skip_2() { } assert_eq!( - Opt::try_parse_from(&["test", "-x", "10", "20", "30"]).unwrap(), + Opt::try_parse_from(["test", "-x", "10", "20", "30"]).unwrap(), Opt { x: 10, ss: String::from(""), @@ -92,7 +92,7 @@ fn skip_enum() { } assert_eq!( - Opt::try_parse_from(&["test", "-n", "10"]).unwrap(), + Opt::try_parse_from(["test", "-n", "10"]).unwrap(), Opt { number: 10, k: Kind::B, @@ -122,7 +122,7 @@ fn skip_help_doc_comments() { } assert_eq!( - Opt::try_parse_from(&["test", "-n", "10"]).unwrap(), + Opt::try_parse_from(["test", "-n", "10"]).unwrap(), Opt { n: 10, a: 0, @@ -147,7 +147,7 @@ fn skip_val() { } assert_eq!( - Opt::try_parse_from(&["test", "-n", "10"]).unwrap(), + Opt::try_parse_from(["test", "-n", "10"]).unwrap(), Opt { number: 10, k: "key".to_string(), diff --git a/tests/derive/subcommands.rs b/tests/derive/subcommands.rs index 2252456f082..3b92cdc5fd3 100644 --- a/tests/derive/subcommands.rs +++ b/tests/derive/subcommands.rs @@ -45,7 +45,7 @@ fn test_fetch() { force: false, repo: "origin".to_string() }, - Opt::try_parse_from(&["test", "fetch", "--all", "origin"]).unwrap() + Opt::try_parse_from(["test", "fetch", "--all", "origin"]).unwrap() ); assert_eq!( Opt::Fetch { @@ -53,7 +53,7 @@ fn test_fetch() { force: true, repo: "origin".to_string() }, - Opt::try_parse_from(&["test", "fetch", "-f", "origin"]).unwrap() + Opt::try_parse_from(["test", "fetch", "-f", "origin"]).unwrap() ); } @@ -64,26 +64,26 @@ fn test_add() { interactive: false, verbose: false }, - Opt::try_parse_from(&["test", "add"]).unwrap() + Opt::try_parse_from(["test", "add"]).unwrap() ); assert_eq!( Opt::Add { interactive: true, verbose: true }, - Opt::try_parse_from(&["test", "add", "-i", "-v"]).unwrap() + Opt::try_parse_from(["test", "add", "-i", "-v"]).unwrap() ); } #[test] fn test_no_parse() { - let result = Opt::try_parse_from(&["test", "badcmd", "-i", "-v"]); + let result = Opt::try_parse_from(["test", "badcmd", "-i", "-v"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "add", "--badoption"]); + let result = Opt::try_parse_from(["test", "add", "--badoption"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test"]); + let result = Opt::try_parse_from(["test"]); assert!(result.is_err()); } @@ -100,7 +100,7 @@ fn test_hyphenated_subcommands() { Opt2::DoSomething { arg: "blah".to_string() }, - Opt2::try_parse_from(&["test", "do-something", "blah"]).unwrap() + Opt2::try_parse_from(["test", "do-something", "blah"]).unwrap() ); } @@ -113,11 +113,11 @@ enum Opt3 { #[test] fn test_null_commands() { - assert_eq!(Opt3::Add, Opt3::try_parse_from(&["test", "add"]).unwrap()); - assert_eq!(Opt3::Init, Opt3::try_parse_from(&["test", "init"]).unwrap()); + assert_eq!(Opt3::Add, Opt3::try_parse_from(["test", "add"]).unwrap()); + assert_eq!(Opt3::Init, Opt3::try_parse_from(["test", "init"]).unwrap()); assert_eq!( Opt3::Fetch, - Opt3::try_parse_from(&["test", "fetch"]).unwrap() + Opt3::try_parse_from(["test", "fetch"]).unwrap() ); } @@ -147,14 +147,14 @@ fn test_tuple_commands() { Opt4::Add(Add { file: "f".to_string() }), - Opt4::try_parse_from(&["test", "add", "f"]).unwrap() + Opt4::try_parse_from(["test", "add", "f"]).unwrap() ); - assert_eq!(Opt4::Init, Opt4::try_parse_from(&["test", "init"]).unwrap()); + assert_eq!(Opt4::Init, Opt4::try_parse_from(["test", "init"]).unwrap()); assert_eq!( Opt4::Fetch(Fetch { remote: "origin".to_string() }), - Opt4::try_parse_from(&["test", "fetch", "origin"]).unwrap() + Opt4::try_parse_from(["test", "fetch", "origin"]).unwrap() ); let output = utils::get_long_help::(); @@ -187,7 +187,7 @@ fn global_passed_down() { } assert_eq!( - Opt::try_parse_from(&["test", "global"]).unwrap(), + Opt::try_parse_from(["test", "global"]).unwrap(), Opt { other: false, sub: Subcommands::Global(GlobalCmd { other: false }) @@ -195,7 +195,7 @@ fn global_passed_down() { ); assert_eq!( - Opt::try_parse_from(&["test", "global", "--other"]).unwrap(), + Opt::try_parse_from(["test", "global", "--other"]).unwrap(), Opt { other: true, sub: Subcommands::Global(GlobalCmd { other: true }) @@ -220,23 +220,23 @@ fn external_subcommand() { } assert_eq!( - Opt::try_parse_from(&["test", "add"]).unwrap(), + Opt::try_parse_from(["test", "add"]).unwrap(), Opt { sub: Subcommands::Add } ); assert_eq!( - Opt::try_parse_from(&["test", "remove"]).unwrap(), + Opt::try_parse_from(["test", "remove"]).unwrap(), Opt { sub: Subcommands::Remove } ); - assert!(Opt::try_parse_from(&["test"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); assert_eq!( - Opt::try_parse_from(&["test", "git", "status"]).unwrap(), + Opt::try_parse_from(["test", "git", "status"]).unwrap(), Opt { sub: Subcommands::Other(vec!["git".into(), "status".into()]) } @@ -260,13 +260,13 @@ fn external_subcommand_os_string() { } assert_eq!( - Opt::try_parse_from(&["test", "git", "status"]).unwrap(), + Opt::try_parse_from(["test", "git", "status"]).unwrap(), Opt { sub: Subcommands::Other(vec!["git".into(), "status".into()]) } ); - assert!(Opt::try_parse_from(&["test"]).is_err()); + assert!(Opt::try_parse_from(["test"]).is_err()); } #[test] @@ -284,13 +284,13 @@ fn external_subcommand_optional() { } assert_eq!( - Opt::try_parse_from(&["test", "git", "status"]).unwrap(), + Opt::try_parse_from(["test", "git", "status"]).unwrap(), Opt { sub: Some(Subcommands::Other(vec!["git".into(), "status".into()])) } ); - assert_eq!(Opt::try_parse_from(&["test"]).unwrap(), Opt { sub: None }); + assert_eq!(Opt::try_parse_from(["test"]).unwrap(), Opt { sub: None }); } #[test] @@ -309,22 +309,22 @@ fn enum_in_enum_subsubcommand() { Stop, } - let result = Opt::try_parse_from(&["test"]); + let result = Opt::try_parse_from(["test"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "list"]).unwrap(); + let result = Opt::try_parse_from(["test", "list"]).unwrap(); assert_eq!(Opt::List, result); - let result = Opt::try_parse_from(&["test", "l"]).unwrap(); + let result = Opt::try_parse_from(["test", "l"]).unwrap(); assert_eq!(Opt::List, result); - let result = Opt::try_parse_from(&["test", "daemon"]); + let result = Opt::try_parse_from(["test", "daemon"]); assert!(result.is_err()); - let result = Opt::try_parse_from(&["test", "daemon", "start"]).unwrap(); + let result = Opt::try_parse_from(["test", "daemon", "start"]).unwrap(); assert_eq!(Opt::Daemon(DaemonCommand::Start), result); - let result = Opt::try_parse_from(&["test", "d", "start"]).unwrap(); + let result = Opt::try_parse_from(["test", "d", "start"]).unwrap(); assert_eq!(Opt::Daemon(DaemonCommand::Start), result); } @@ -350,26 +350,26 @@ fn update_subcommands() { // Full subcommand update let mut opt = Opt::Command1(Command1 { arg1: 12, arg2: 14 }); - opt.try_update_from(&["test", "command1", "42", "44"]) + opt.try_update_from(["test", "command1", "42", "44"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command1", "42", "44"]).unwrap(), + Opt::try_parse_from(["test", "command1", "42", "44"]).unwrap(), opt ); // Partial subcommand update let mut opt = Opt::Command1(Command1 { arg1: 12, arg2: 14 }); - opt.try_update_from(&["test", "command1", "42"]).unwrap(); + opt.try_update_from(["test", "command1", "42"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command1", "42", "14"]).unwrap(), + Opt::try_parse_from(["test", "command1", "42", "14"]).unwrap(), opt ); // Change subcommand let mut opt = Opt::Command1(Command1 { arg1: 12, arg2: 14 }); - opt.try_update_from(&["test", "command2", "43"]).unwrap(); + opt.try_update_from(["test", "command2", "43"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command2", "43"]).unwrap(), + Opt::try_parse_from(["test", "command2", "43"]).unwrap(), opt ); } @@ -410,37 +410,37 @@ fn update_sub_subcommands() { // Full subcommand update let mut opt = Opt::Child1(Child1::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "child1", "command1", "42", "44"]) + opt.try_update_from(["test", "child1", "command1", "42", "44"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "child1", "command1", "42", "44"]).unwrap(), + Opt::try_parse_from(["test", "child1", "command1", "42", "44"]).unwrap(), opt ); // Partial subcommand update let mut opt = Opt::Child1(Child1::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "child1", "command1", "42"]) + opt.try_update_from(["test", "child1", "command1", "42"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "child1", "command1", "42", "14"]).unwrap(), + Opt::try_parse_from(["test", "child1", "command1", "42", "14"]).unwrap(), opt ); // Partial subcommand update let mut opt = Opt::Child1(Child1::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "child1", "command2", "43"]) + opt.try_update_from(["test", "child1", "command2", "43"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "child1", "command2", "43"]).unwrap(), + Opt::try_parse_from(["test", "child1", "command2", "43"]).unwrap(), opt ); // Change subcommand let mut opt = Opt::Child1(Child1::Command1(Command1 { arg1: 12, arg2: 14 })); - opt.try_update_from(&["test", "child2", "command2", "43"]) + opt.try_update_from(["test", "child2", "command2", "43"]) .unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "child2", "command2", "43"]).unwrap(), + Opt::try_parse_from(["test", "child2", "command2", "43"]).unwrap(), opt ); } @@ -469,29 +469,29 @@ fn update_ext_subcommand() { // Full subcommand update let mut opt = Opt::Ext(vec!["12".into(), "14".into()]); - opt.try_update_from(&["test", "ext", "42", "44"]).unwrap(); + opt.try_update_from(["test", "ext", "42", "44"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "ext", "42", "44"]).unwrap(), + Opt::try_parse_from(["test", "ext", "42", "44"]).unwrap(), opt ); // No partial subcommand update let mut opt = Opt::Ext(vec!["12".into(), "14".into()]); - opt.try_update_from(&["test", "ext", "42"]).unwrap(); - assert_eq!(Opt::try_parse_from(&["test", "ext", "42"]).unwrap(), opt); + opt.try_update_from(["test", "ext", "42"]).unwrap(); + assert_eq!(Opt::try_parse_from(["test", "ext", "42"]).unwrap(), opt); // Change subcommand let mut opt = Opt::Ext(vec!["12".into(), "14".into()]); - opt.try_update_from(&["test", "command2", "43"]).unwrap(); + opt.try_update_from(["test", "command2", "43"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "command2", "43"]).unwrap(), + Opt::try_parse_from(["test", "command2", "43"]).unwrap(), opt ); let mut opt = Opt::Command1(Command1 { arg1: 12, arg2: 14 }); - opt.try_update_from(&["test", "ext", "42", "44"]).unwrap(); + opt.try_update_from(["test", "ext", "42", "44"]).unwrap(); assert_eq!( - Opt::try_parse_from(&["test", "ext", "42", "44"]).unwrap(), + Opt::try_parse_from(["test", "ext", "42", "44"]).unwrap(), opt ); } @@ -513,7 +513,7 @@ fn subcommand_name_not_literal() { SubCmd1, } - assert!(Opt::try_parse_from(&["test", "renamed"]).is_ok()); + assert!(Opt::try_parse_from(["test", "renamed"]).is_ok()); } #[test] @@ -551,26 +551,26 @@ fn skip_subcommand() { assert!(!Subcommands::has_subcommand("other")); assert_eq!( - Opt::try_parse_from(&["test", "add"]).unwrap(), + Opt::try_parse_from(["test", "add"]).unwrap(), Opt { sub: Subcommands::Add } ); assert_eq!( - Opt::try_parse_from(&["test", "remove"]).unwrap(), + Opt::try_parse_from(["test", "remove"]).unwrap(), Opt { sub: Subcommands::Remove } ); - let res = Opt::try_parse_from(&["test", "skip"]); + let res = Opt::try_parse_from(["test", "skip"]); assert_eq!( res.unwrap_err().kind(), clap::error::ErrorKind::InvalidSubcommand, ); - let res = Opt::try_parse_from(&["test", "other"]); + let res = Opt::try_parse_from(["test", "other"]); assert_eq!( res.unwrap_err().kind(), clap::error::ErrorKind::InvalidSubcommand, @@ -589,17 +589,17 @@ fn built_in_subcommand_escaped() { } assert_eq!( - Command::try_parse_from(&["test", "install", "arg"]).unwrap(), + Command::try_parse_from(["test", "install", "arg"]).unwrap(), Command::Install { arg: Some(String::from("arg")) } ); assert_eq!( - Command::try_parse_from(&["test", "--", "install"]).unwrap(), + Command::try_parse_from(["test", "--", "install"]).unwrap(), Command::Custom(vec![String::from("install")]) ); assert_eq!( - Command::try_parse_from(&["test", "--", "install", "arg"]).unwrap(), + Command::try_parse_from(["test", "--", "install", "arg"]).unwrap(), Command::Custom(vec![String::from("install"), String::from("arg")]) ); } diff --git a/tests/derive/value_enum.rs b/tests/derive/value_enum.rs index c7865049303..e0ed09bc161 100644 --- a/tests/derive/value_enum.rs +++ b/tests/derive/value_enum.rs @@ -27,15 +27,15 @@ fn basic() { Opt { arg: ArgChoice::Foo }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Bar }, - Opt::try_parse_from(&["", "bar"]).unwrap() + Opt::try_parse_from(["", "bar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "fOo"]).is_err()); } #[test] @@ -62,19 +62,19 @@ fn default_value() { Opt { arg: ArgChoice::Foo }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Bar }, - Opt::try_parse_from(&["", "bar"]).unwrap() + Opt::try_parse_from(["", "bar"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Bar }, - Opt::try_parse_from(&[""]).unwrap() + Opt::try_parse_from([""]).unwrap() ); } @@ -104,28 +104,28 @@ fn vec_for_default_values_t() { arg1: vec![ArgChoice::Foo], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg1: vec![ArgChoice::Bar], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&["", "bar"]).unwrap() + Opt::try_parse_from(["", "bar"]).unwrap() ); assert_eq!( Opt { arg1: vec![ArgChoice::Foo, ArgChoice::Bar], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&[""]).unwrap() + Opt::try_parse_from([""]).unwrap() ); assert_eq!( Opt { arg1: vec![ArgChoice::Foo, ArgChoice::Bar], arg2: vec![ArgChoice::Foo] }, - Opt::try_parse_from(&["", "--arg2", "foo"]).unwrap() + Opt::try_parse_from(["", "--arg2", "foo"]).unwrap() ); } @@ -155,28 +155,28 @@ fn vec_for_default_values_os_t() { arg: vec![ArgChoice::Foo], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg: vec![ArgChoice::Bar], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&["", "bar"]).unwrap() + Opt::try_parse_from(["", "bar"]).unwrap() ); assert_eq!( Opt { arg: vec![ArgChoice::Foo, ArgChoice::Bar], arg2: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&[""]).unwrap() + Opt::try_parse_from([""]).unwrap() ); assert_eq!( Opt { arg: vec![ArgChoice::Foo, ArgChoice::Bar], arg2: vec![ArgChoice::Foo] }, - Opt::try_parse_from(&["", "--arg2", "foo"]).unwrap() + Opt::try_parse_from(["", "--arg2", "foo"]).unwrap() ); } @@ -199,15 +199,15 @@ fn multi_word_is_renamed_kebab() { Opt { arg: ArgChoice::FooBar }, - Opt::try_parse_from(&["", "foo-bar"]).unwrap() + Opt::try_parse_from(["", "foo-bar"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::BAR_BAZ }, - Opt::try_parse_from(&["", "bar-baz"]).unwrap() + Opt::try_parse_from(["", "bar-baz"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "FooBar"]).is_err()); + assert!(Opt::try_parse_from(["", "FooBar"]).is_err()); } #[test] @@ -228,9 +228,9 @@ fn variant_with_defined_casing() { Opt { arg: ArgChoice::FooBar }, - Opt::try_parse_from(&["", "FOO_BAR"]).unwrap() + Opt::try_parse_from(["", "FOO_BAR"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "FooBar"]).is_err()); + assert!(Opt::try_parse_from(["", "FooBar"]).is_err()); } #[test] @@ -251,9 +251,9 @@ fn casing_is_propagated_from_parent() { Opt { arg: ArgChoice::FooBar }, - Opt::try_parse_from(&["", "FOO_BAR"]).unwrap() + Opt::try_parse_from(["", "FOO_BAR"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "FooBar"]).is_err()); + assert!(Opt::try_parse_from(["", "FooBar"]).is_err()); } #[test] @@ -275,10 +275,10 @@ fn casing_propagation_is_overridden() { Opt { arg: ArgChoice::FooBar }, - Opt::try_parse_from(&["", "fooBar"]).unwrap() + Opt::try_parse_from(["", "fooBar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "FooBar"]).is_err()); - assert!(Opt::try_parse_from(&["", "FOO_BAR"]).is_err()); + assert!(Opt::try_parse_from(["", "FooBar"]).is_err()); + assert!(Opt::try_parse_from(["", "FOO_BAR"]).is_err()); } #[test] @@ -298,13 +298,13 @@ fn ignore_case() { Opt { arg: ArgChoice::Foo }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Foo }, - Opt::try_parse_from(&["", "fOo"]).unwrap() + Opt::try_parse_from(["", "fOo"]).unwrap() ); } @@ -325,9 +325,9 @@ fn ignore_case_set_to_false() { Opt { arg: ArgChoice::Foo }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "fOo"]).is_err()); } #[test] @@ -348,13 +348,13 @@ fn alias() { Opt { arg: ArgChoice::Totp }, - Opt::try_parse_from(&["", "totp"]).unwrap() + Opt::try_parse_from(["", "totp"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Totp }, - Opt::try_parse_from(&["", "TOTP"]).unwrap() + Opt::try_parse_from(["", "TOTP"]).unwrap() ); } @@ -376,19 +376,19 @@ fn multiple_alias() { Opt { arg: ArgChoice::Totp }, - Opt::try_parse_from(&["", "totp"]).unwrap() + Opt::try_parse_from(["", "totp"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Totp }, - Opt::try_parse_from(&["", "TOTP"]).unwrap() + Opt::try_parse_from(["", "TOTP"]).unwrap() ); assert_eq!( Opt { arg: ArgChoice::Totp }, - Opt::try_parse_from(&["", "t"]).unwrap() + Opt::try_parse_from(["", "t"]).unwrap() ); } @@ -481,20 +481,20 @@ fn option_type() { arg: Option, } - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&[""]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from([""]).unwrap()); assert_eq!( Opt { arg: Some(ArgChoice::Foo) }, - Opt::try_parse_from(&["", "foo"]).unwrap() + Opt::try_parse_from(["", "foo"]).unwrap() ); assert_eq!( Opt { arg: Some(ArgChoice::Bar) }, - Opt::try_parse_from(&["", "bar"]).unwrap() + Opt::try_parse_from(["", "bar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "fOo"]).is_err()); } #[test] @@ -511,24 +511,24 @@ fn option_option_type() { arg: Option>, } - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&[""]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from([""]).unwrap()); assert_eq!( Opt { arg: Some(None) }, - Opt::try_parse_from(&["", "--arg"]).unwrap() + Opt::try_parse_from(["", "--arg"]).unwrap() ); assert_eq!( Opt { arg: Some(Some(ArgChoice::Foo)) }, - Opt::try_parse_from(&["", "--arg", "foo"]).unwrap() + Opt::try_parse_from(["", "--arg", "foo"]).unwrap() ); assert_eq!( Opt { arg: Some(Some(ArgChoice::Bar)) }, - Opt::try_parse_from(&["", "--arg", "bar"]).unwrap() + Opt::try_parse_from(["", "--arg", "bar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "--arg", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "--arg", "fOo"]).is_err()); } #[test] @@ -545,20 +545,20 @@ fn vec_type() { arg: Vec, } - assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from(&[""]).unwrap()); + assert_eq!(Opt { arg: vec![] }, Opt::try_parse_from([""]).unwrap()); assert_eq!( Opt { arg: vec![ArgChoice::Foo] }, - Opt::try_parse_from(&["", "-a", "foo"]).unwrap() + Opt::try_parse_from(["", "-a", "foo"]).unwrap() ); assert_eq!( Opt { arg: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&["", "-a", "foo", "-a", "bar"]).unwrap() + Opt::try_parse_from(["", "-a", "foo", "-a", "bar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "-a", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "-a", "fOo"]).is_err()); } #[test] @@ -575,20 +575,20 @@ fn option_vec_type() { arg: Option>, } - assert_eq!(Opt { arg: None }, Opt::try_parse_from(&[""]).unwrap()); + assert_eq!(Opt { arg: None }, Opt::try_parse_from([""]).unwrap()); assert_eq!( Opt { arg: Some(vec![ArgChoice::Foo]) }, - Opt::try_parse_from(&["", "-a", "foo"]).unwrap() + Opt::try_parse_from(["", "-a", "foo"]).unwrap() ); assert_eq!( Opt { arg: Some(vec![ArgChoice::Foo, ArgChoice::Bar]) }, - Opt::try_parse_from(&["", "-a", "foo", "-a", "bar"]).unwrap() + Opt::try_parse_from(["", "-a", "foo", "-a", "bar"]).unwrap() ); - assert!(Opt::try_parse_from(&["", "-a", "fOo"]).is_err()); + assert!(Opt::try_parse_from(["", "-a", "fOo"]).is_err()); } #[test] @@ -616,13 +616,13 @@ fn vec_type_default_value() { Opt { arg: vec![ArgChoice::Foo, ArgChoice::Bar] }, - Opt::try_parse_from(&[""]).unwrap() + Opt::try_parse_from([""]).unwrap() ); assert_eq!( Opt { arg: vec![ArgChoice::Foo, ArgChoice::Baz] }, - Opt::try_parse_from(&["", "-a", "foo,baz"]).unwrap() + Opt::try_parse_from(["", "-a", "foo,baz"]).unwrap() ); }