diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index ed69ecb9..0b5c405d 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -115,7 +115,7 @@ impl<'help> App<'help> { /// Get the long flag of the subcommand. #[inline] - pub fn get_long_flag(&self) -> Option<&str> { + pub fn get_long_flag(&self) -> Option<&'help str> { self.long_flag } @@ -134,7 +134,7 @@ impl<'help> App<'help> { /// /// [`App::about`]: App::about() #[inline] - pub fn get_about(&self) -> Option<&str> { + pub fn get_about(&self) -> Option<&'help str> { self.about } @@ -142,7 +142,7 @@ impl<'help> App<'help> { /// /// [`App::long_about`]: App::long_about() #[inline] - pub fn get_long_about(&self) -> Option<&str> { + pub fn get_long_about(&self) -> Option<&'help str> { self.long_about } @@ -156,7 +156,7 @@ impl<'help> App<'help> { /// Iterate through the *visible* aliases for this subcommand. #[inline] - pub fn get_visible_aliases(&self) -> impl Iterator { + pub fn get_visible_aliases(&self) -> impl Iterator + '_ { self.aliases.iter().filter(|(_, vis)| *vis).map(|a| a.0) } @@ -180,7 +180,7 @@ impl<'help> App<'help> { /// Iterate through the set of *all* the aliases for this subcommand, both visible and hidden. #[inline] - pub fn get_all_aliases(&self) -> impl Iterator { + pub fn get_all_aliases(&self) -> impl Iterator + '_ { self.aliases.iter().map(|a| a.0) } diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index 8d57d0e8..a3aab301 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -128,13 +128,13 @@ pub struct Arg<'help> { impl<'help> Arg<'help> { /// Get the name of the argument #[inline] - pub fn get_name(&self) -> &str { + pub fn get_name(&self) -> &'help str { self.name } /// Get the help specified for this argument, if any #[inline] - pub fn get_about(&self) -> Option<&str> { + pub fn get_about(&self) -> Option<&'help str> { self.about } @@ -149,13 +149,13 @@ impl<'help> Arg<'help> { /// ``` /// #[inline] - pub fn get_long_about(&self) -> Option<&str> { + pub fn get_long_about(&self) -> Option<&'help str> { self.long_about } /// Get the help heading specified for this argument, if any #[inline] - pub fn get_help_heading(&self) -> Option<&str> { + pub fn get_help_heading(&self) -> Option<&'help str> { self.help_heading.unwrap_or_default() } @@ -196,13 +196,13 @@ impl<'help> Arg<'help> { /// Get the long option name for this argument, if any #[inline] - pub fn get_long(&self) -> Option<&str> { + pub fn get_long(&self) -> Option<&'help str> { self.long } /// Get visible aliases for this argument, if any #[inline] - pub fn get_visible_aliases(&self) -> Option> { + pub fn get_visible_aliases(&self) -> Option> { if self.aliases.is_empty() { None } else { @@ -218,7 +218,7 @@ impl<'help> Arg<'help> { /// Get the long option name and its visible aliases, if any #[inline] - pub fn get_long_and_visible_aliases(&self) -> Option> { + pub fn get_long_and_visible_aliases(&self) -> Option> { let mut longs = match self.long { Some(long) => vec![long], None => return None, @@ -241,7 +241,7 @@ impl<'help> Arg<'help> { /// Get the names of values for this argument. #[inline] - pub fn get_value_names(&self) -> Option<&[&str]> { + pub fn get_value_names(&self) -> Option<&[&'help str]> { if self.val_names.is_empty() { None } else { diff --git a/tests/tests.rs b/tests/tests.rs index ec6f5e5b..7b675529 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -3,7 +3,7 @@ mod utils; use std::io::Write; use std::str; -use clap::{App, Arg}; +use clap::{App, Arg, ArgSettings}; static SCF2OP: &str = "flag present 2 times option NOT present @@ -390,3 +390,17 @@ fn sc_short_flag_x2_short_opt_eq_pos() { fn sc_short_flag_x2_long_opt_eq_pos() { check_complex_output("clap-test subcmd value -f -f --option=some", SCF2OP); } + +#[test] +fn mut_arg_all() { + let mut app = utils::complex_app(); + let arg_names = app + .get_arguments() + .map(|a| a.get_name()) + .filter(|a| *a != "version" && *a != "help") + .collect::>(); + + for arg_name in arg_names { + app = app.mut_arg(arg_name, |arg| arg.setting(ArgSettings::HidePossibleValues)); + } +}