Repository: clap-rs/clap
Pull request #2345 (2021-02-13 15:47:51)

Change some u64 to usize
<!--
If your PR closes some issues, please write `Closes #XXXX`
where `XXXX` is the number of the issue you want to fix.
Each issue goes on its own line.
-->
Reduce unneeded number casting.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e69b014..e0660b25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,9 +10,6 @@ TODO: `cargo`, `std` features
 
 #### BREAKING CHANGES
 
-* **Removed Methods**
-  * **Arg**
-    * `Arg::settings` in favor of `Arg::setting(Setting1 | Setting2)`
 * **Renamed Settings**
   * `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag`
   * `AppSettings::DisableVersion` => `AppSettings::DisableVersionFlag`
@@ -199,7 +196,6 @@ TODO: `cargo`, `std` features
     * `Arg::multiple_values`
     * `Arg::multiple_occurrences`
     * `Arg::help_heading`
-    * `Arg::settings`
 * **Added Settings**
   * `AppSettings::HelpRequired`
   * `AppSettings::NoAutoHelp`
diff --git a/benches/03_complex.rs b/benches/03_complex.rs
index 4e152dd3..04979b42 100644
--- a/benches/03_complex.rs
+++ b/benches/03_complex.rs
@@ -67,7 +67,7 @@ pub fn build_from_builder(c: &mut Criterion) {
                         .about("tests flags")
                         .long("flag")
                         .global(true)
-                        .setting(ArgSettings::MultipleOccurrences),
+                        .settings(&[ArgSettings::MultipleOccurrences]),
                 )
                 .arg(
                     Arg::new("flag2")
diff --git a/benches/04_new_help.rs b/benches/04_new_help.rs
index 3b2f7149..f245111e 100644
--- a/benches/04_new_help.rs
+++ b/benches/04_new_help.rs
@@ -112,9 +112,11 @@ fn app_example7<'c>() -> App<'c> {
         .arg(
             Arg::new("input")
                 .about("the input file to use")
-                .setting(ArgSettings::MultipleValues)
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::Required)
+                .settings(&[
+                    ArgSettings::MultipleValues,
+                    ArgSettings::MultipleOccurrences,
+                    ArgSettings::Required,
+                ])
                 .short('i')
                 .long("input")
                 .requires("config")
@@ -129,9 +131,11 @@ fn app_example8<'c>() -> App<'c> {
         .arg(
             Arg::new("input")
                 .about("the input file to use")
-                .setting(ArgSettings::MultipleValues)
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::Required)
+                .settings(&[
+                    ArgSettings::MultipleValues,
+                    ArgSettings::MultipleOccurrences,
+                    ArgSettings::Required,
+                ])
                 .short('i')
                 .long("input")
                 .requires("config")
diff --git a/benches/05_ripgrep.rs b/benches/05_ripgrep.rs
index 866e8e95..ebde55e2 100644
--- a/benches/05_ripgrep.rs
+++ b/benches/05_ripgrep.rs
@@ -332,9 +332,11 @@ where
         .arg(
             flag("regexp")
                 .short('e')
-                .setting(ArgSettings::AllowHyphenValues)
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::TakesValue)
+                .settings(&[
+                    ArgSettings::AllowHyphenValues,
+                    ArgSettings::MultipleOccurrences,
+                    ArgSettings::TakesValue,
+                ])
                 .value_name("pattern"),
         )
         .arg(
@@ -356,15 +358,13 @@ where
         .arg(
             flag("colors")
                 .value_name("SPEC")
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::TakesValue),
+                .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue]),
         )
         .arg(flag("fixed-strings").short('F'))
         .arg(
             flag("glob")
                 .short('g')
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::TakesValue)
+                .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
                 .value_name("GLOB"),
         )
         .arg(flag("ignore-case").short('i'))
@@ -374,15 +374,13 @@ where
         .arg(
             flag("type")
                 .short('t')
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::TakesValue)
+                .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
                 .value_name("TYPE"),
         )
         .arg(
             flag("type-not")
                 .short('T')
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::TakesValue)
+                .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
                 .value_name("TYPE"),
         )
         .arg(
diff --git a/benches/06_rustup.rs b/benches/06_rustup.rs
index e056aa26..907ad702 100644
--- a/benches/06_rustup.rs
+++ b/benches/06_rustup.rs
@@ -262,12 +262,11 @@ fn build_cli() -> App<'static> {
                 .after_help(RUN_HELP)
                 .setting(AppSettings::TrailingVarArg)
                 .arg(Arg::new("toolchain").setting(ArgSettings::Required))
-                .arg(
-                    Arg::new("command")
-                        .setting(ArgSettings::Required)
-                        .setting(ArgSettings::MultipleValues)
-                        .setting(ArgSettings::MultipleOccurrences),
-                ),
+                .arg(Arg::new("command").settings(&[
+                    ArgSettings::Required,
+                    ArgSettings::MultipleValues,
+                    ArgSettings::MultipleOccurrences,
+                ])),
         )
         .subcommand(
             App::new("which")
diff --git a/clap.schema.json b/clap.schema.json
index 80997e25..4fa922bd 100644
--- a/clap.schema.json
+++ b/clap.schema.json
@@ -51,6 +51,7 @@
   "definitions": {
     "arg": {
       "type": "object",
+
       "properties": {
         "about": {
           "type": "string"
@@ -314,6 +315,7 @@
       "type": "string"
     }
   },
+
   "type": "object",
   "TODO:": "set 'name' as required",
   "properties": {
diff --git a/examples/16_app_settings.rs b/examples/16_app_settings.rs
index 11e3c5f0..68c06f32 100644
--- a/examples/16_app_settings.rs
+++ b/examples/16_app_settings.rs
@@ -2,8 +2,9 @@ use clap::{App, AppSettings};
 
 fn main() {
     // You can use AppSettings to change the application level behavior of clap. .setting() function
-    // of App struct takes AppSettings enum as argument. You can learn more about AppSettings in the
-    // documentation, which also has examples on each setting.
+    // of App struct takes AppSettings enum as argument. There is also .settings() function which
+    // takes slice of AppSettings enum.  You can learn more about AppSettings in the documentation,
+    // which also has examples on each setting.
     //
     // This example will only show usage of one AppSettings setting. See documentation for more
     // information.
diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs
index 6b2c93bf..a5a0c2eb 100644
--- a/src/build/app/mod.rs
+++ b/src/build/app/mod.rs
@@ -918,6 +918,7 @@ impl<'help> App<'help> {
     /// # ;
     /// ```
     /// [`AppSettings`]: ./enum.AppSettings.html
+    /// [global]: ./struct.App.html#method.global_setting
     #[inline]
     pub fn unset_setting(mut self, setting: AppSettings) -> Self {
         self.settings.unset(setting);
diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs
index 3d0f70ad..45eafa5c 100644
--- a/src/build/arg/mod.rs
+++ b/src/build/arg/mod.rs
@@ -100,9 +100,9 @@ pub struct Arg<'help> {
     pub(crate) unified_ord: usize,
     pub(crate) possible_vals: Vec<&'help str>,
     pub(crate) val_names: VecMap<&'help str>,
-    pub(crate) num_vals: Option<u64>,
-    pub(crate) max_vals: Option<u64>,
-    pub(crate) min_vals: Option<u64>,
+    pub(crate) num_vals: Option<usize>,
+    pub(crate) max_vals: Option<usize>,
+    pub(crate) min_vals: Option<usize>,
     pub(crate) validator: Option<Arc<Mutex<Validator<'help>>>>,
     pub(crate) validator_os: Option<Arc<Mutex<ValidatorOs<'help>>>>,
     pub(crate) val_delim: Option<char>,
@@ -111,7 +111,7 @@ pub struct Arg<'help> {
     pub(crate) default_missing_vals: Vec<&'help OsStr>,
     pub(crate) env: Option<(&'help OsStr, Option<OsString>)>,
     pub(crate) terminator: Option<&'help str>,
-    pub(crate) index: Option<u64>,
+    pub(crate) index: Option<usize>,
     pub(crate) help_heading: Option<&'help str>,
     pub(crate) global: bool,
     pub(crate) exclusive: bool,
@@ -178,7 +178,7 @@ impl<'help> Arg<'help> {
 
     /// Get the index of this argument, if any
     #[inline]
-    pub fn get_index(&self) -> Option<u64> {
+    pub fn get_index(&self) -> Option<usize> {
         self.index
     }
 
@@ -1591,7 +1591,7 @@ impl<'help> Arg<'help> {
     /// [`App`]: ./struct.App.html
     /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
     #[inline]
-    pub fn index(mut self, idx: u64) -> Self {
+    pub fn index(mut self, idx: usize) -> Self {
         self.index = Some(idx);
         self
     }
@@ -1865,7 +1865,7 @@ impl<'help> Arg<'help> {
     /// ```
     /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
     #[inline]
-    pub fn number_of_values(mut self, qty: u64) -> Self {
+    pub fn number_of_values(mut self, qty: usize) -> Self {
         self.num_vals = Some(qty);
         self.takes_value(true)
     }
@@ -2087,7 +2087,7 @@ impl<'help> Arg<'help> {
     /// ```
     /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
     #[inline]
-    pub fn max_values(mut self, qty: u64) -> Self {
+    pub fn max_values(mut self, qty: usize) -> Self {
         self.max_vals = Some(qty);
         self.takes_value(true).multiple_values(true)
     }
@@ -2150,7 +2150,7 @@ impl<'help> Arg<'help> {
     /// ```
     /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
     #[inline]
-    pub fn min_values(mut self, qty: u64) -> Self {
+    pub fn min_values(mut self, qty: usize) -> Self {
         self.min_vals = Some(qty);
         self.takes_value(true)
     }
@@ -3058,11 +3058,10 @@ impl<'help> Arg<'help> {
     /// # use clap::{App, Arg, ArgSettings};
     /// let res = App::new("prog")
     ///     .arg(Arg::new("cfg")
-    ///         .setting(ArgSettings::Required)
-    ///         .setting(ArgSettings::TakesValue)
+    ///         .settings(&[ArgSettings::Required, ArgSettings::TakesValue])
     ///         .long("config"))
     ///     .try_get_matches_from(vec![
-    ///         "prog", "--config", "file.conf",
+    ///         "prog", "--config", "file.conf"
     ///     ]);
     ///
     /// assert!(res.is_ok());
@@ -3074,8 +3073,7 @@ impl<'help> Arg<'help> {
     /// # use clap::{App, Arg, ArgSettings, ErrorKind};
     /// let res = App::new("prog")
     ///     .arg(Arg::new("cfg")
-    ///         .setting(ArgSettings::Required)
-    ///         .setting(ArgSettings::TakesValue)
+    ///         .settings(&[ArgSettings::Required, ArgSettings::TakesValue])
     ///         .long("config"))
     ///     .try_get_matches_from(vec![
     ///         "prog"
@@ -3342,8 +3340,7 @@ impl<'help> Arg<'help> {
     /// let delims = App::new("prog")
     ///     .arg(Arg::new("opt")
     ///         .short('o')
-    ///         .setting(ArgSettings::RequireDelimiter)
-    ///         .setting(ArgSettings::MultipleValues))
+    ///         .settings(&[ArgSettings::RequireDelimiter, ArgSettings::MultipleValues]))
     ///     .get_matches_from(vec![
     ///         "prog", "-o", "val1,val2,val3",
     ///     ]);
@@ -3548,8 +3545,7 @@ impl<'help> Arg<'help> {
     ///     .arg(Arg::new("option")
     ///         .short('o')
     ///         .long("--option")
-    ///         .setting(ArgSettings::IgnoreCase)
-    ///         .setting(ArgSettings::MultipleValues)
+    ///         .settings(&[ArgSettings::IgnoreCase, ArgSettings::MultipleValues])
     ///         .possible_value("test123")
     ///         .possible_value("test321"))
     ///     .get_matches_from(vec![
@@ -3717,8 +3713,7 @@ impl<'help> Arg<'help> {
     ///     .arg(Arg::new("opt")
     ///         .long("long-option-flag")
     ///         .short('o')
-    ///         .setting(ArgSettings::TakesValue)
-    ///         .setting(ArgSettings::NextLineHelp)
+    ///         .settings(&[ArgSettings::TakesValue, ArgSettings::NextLineHelp])
     ///         .value_names(&["value1", "value2"])
     ///         .about("Some really long help and complex\n\
     ///                help that makes more sense to be\n\
@@ -3893,8 +3888,7 @@ impl<'help> Arg<'help> {
     /// # use clap::{App, Arg, ArgSettings};
     /// let m = App::new("prog")
     ///     .arg(Arg::new("file")
-    ///         .setting(ArgSettings::MultipleOccurrences)
-    ///         .setting(ArgSettings::TakesValue)
+    ///         .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
     ///         .short('F'))
     ///     .arg(Arg::new("word")
     ///         .index(1))
@@ -3914,8 +3908,7 @@ impl<'help> Arg<'help> {
     /// # use clap::{App, Arg, ErrorKind, ArgSettings};
     /// let res = App::new("prog")
     ///     .arg(Arg::new("file")
-    ///         .setting(ArgSettings::MultipleOccurrences)
-    ///         .setting(ArgSettings::TakesValue)
+    ///         .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
     ///         .short('F'))
     ///     .arg(Arg::new("word")
     ///         .index(1))
@@ -4039,8 +4032,7 @@ impl<'help> Arg<'help> {
     /// # use clap::{App, Arg, ArgSettings};
     /// let m = App::new("prog")
     ///     .arg(Arg::new("file")
-    ///         .setting(ArgSettings::MultipleOccurrences)
-    ///         .setting(ArgSettings::TakesValue)
+    ///         .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::TakesValue])
     ///         .short('F'))
     ///     .get_matches_from(vec![
     ///         "prog", "-F", "file1", "-F", "file2", "-F", "file3"
@@ -4260,42 +4252,32 @@ impl<'help> Arg<'help> {
         self.settings.is_set(s)
     }
 
-    /// Enables a single setting for the current (this `Arg` instance) argument.
-    ///
-    /// See [`ArgSettings`] for a full list of possibilities and examples.
-    ///
-    /// # Examples
+    /// Sets one of the [`ArgSettings`] settings for the argument
     ///
-    /// ```no_run
-    /// # use clap::{Arg, ArgSettings};
-    /// Arg::new("config")
-    ///     .setting(ArgSettings::Required)
-    ///     .setting(ArgSettings::TakesValue)
-    /// # ;
-    /// ```
     /// [`ArgSettings`]: ./enum.ArgSettings.html
     #[inline]
-    pub fn setting(mut self, setting: ArgSettings) -> Self {
-        self.settings.set(setting);
+    pub fn setting(mut self, s: ArgSettings) -> Self {
+        self.set_mut(s);
         self
     }
 
-    /// Disables a single setting for the current (this `Arg` instance) argument.
-    ///
-    /// See [`ArgSettings`] for a full list of possibilities and examples.
+    // @TODO @docs @v3-beta: write better docs as ArgSettings is now critical
+    /// Sets multiple [`ArgSettings`] for the argument
     ///
-    /// # Examples
+    /// [`ArgSettings`]: ./enum.ArgSettings.html
+    pub fn settings(mut self, settings: &[ArgSettings]) -> Self {
+        for s in settings {
+            self.settings.set(*s);
+        }
+        self
+    }
+
+    /// Unsets one of the [`ArgSettings`] for the argument
     ///
-    /// ```no_run
-    /// # use clap::{Arg, ArgSettings};
-    /// Arg::new("config")
-    ///     .unset_setting(ArgSettings::Required)
-    /// # ;
-    /// ```
     /// [`ArgSettings`]: ./enum.ArgSettings.html
     #[inline]
-    pub fn unset_setting(mut self, setting: ArgSettings) -> Self {
-        self.settings.unset(setting);
+    pub fn unset_setting(mut self, s: ArgSettings) -> Self {
+        self.unset_mut(s);
         self
     }
 
@@ -4333,7 +4315,7 @@ impl<'help> Arg<'help> {
     /// # ;
     /// ```
     pub fn value_hint(mut self, value_hint: ValueHint) -> Self {
-        self.settings.set(ArgSettings::TakesValue);
+        self.set_mut(ArgSettings::TakesValue);
         self.value_hint = value_hint;
         self
     }
@@ -4352,14 +4334,22 @@ impl<'help> Arg<'help> {
                 || self.min_vals.is_some()
                 || (self.num_vals.is_some() && self.num_vals.unwrap() > 1)
             {
-                self.settings.set(ArgSettings::MultipleValues);
-                self.settings.set(ArgSettings::MultipleOccurrences);
+                self.set_mut(ArgSettings::MultipleValues);
+                self.set_mut(ArgSettings::MultipleOccurrences);
             }
         } else if self.is_set(ArgSettings::TakesValue) && self.val_names.len() > 1 {
-            self.num_vals = Some(self.val_names.len() as u64);
+            self.num_vals = Some(self.val_names.len());
         }
     }
 
+    pub(crate) fn set_mut(&mut self, s: ArgSettings) {
+        self.settings.set(s);
+    }
+
+    pub(crate) fn unset_mut(&mut self, s: ArgSettings) {
+        self.settings.unset(s);
+    }
+
     pub(crate) fn has_switch(&self) -> bool {
         self.short.is_some() || self.long.is_some()
     }
@@ -4497,15 +4487,15 @@ impl<'help> From<&'help Yaml> for Arg<'help> {
                 "required_if_eq" => yaml_tuple2!(a, v, required_if_eq),
                 "required_if_eq_any" => yaml_tuple2!(a, v, required_if_eq),
                 "takes_value" => yaml_to_bool!(a, v, takes_value),
-                "index" => yaml_to_u64!(a, v, index),
+                "index" => yaml_to_usize!(a, v, index),
                 "global" => yaml_to_bool!(a, v, global),
                 "multiple" => yaml_to_bool!(a, v, multiple),
                 "hidden" => yaml_to_bool!(a, v, hidden),
                 "next_line_help" => yaml_to_bool!(a, v, next_line_help),
                 "group" => yaml_to_str!(a, v, group),
-                "number_of_values" => yaml_to_u64!(a, v, number_of_values),
-                "max_values" => yaml_to_u64!(a, v, max_values),
-                "min_values" => yaml_to_u64!(a, v, min_values),
+                "number_of_values" => yaml_to_usize!(a, v, number_of_values),
+                "max_values" => yaml_to_usize!(a, v, max_values),
+                "min_values" => yaml_to_usize!(a, v, min_values),
                 "value_name" => yaml_to_str!(a, v, value_name),
                 "use_delimiter" => yaml_to_bool!(a, v, use_delimiter),
                 "allow_hyphen_values" => yaml_to_bool!(a, v, allow_hyphen_values),
@@ -4534,7 +4524,7 @@ impl<'help> From<&'help Yaml> for Arg<'help> {
                 "required_unless_present_any" => yaml_vec!(a, v, required_unless_present_any),
                 "required_unless_present_all" => {
                     a = yaml_vec!(a, v, required_unless_present_all);
-                    a.settings.set(ArgSettings::RequiredUnlessAll);
+                    a.set_mut(ArgSettings::RequiredUnlessAll);
                     a
                 }
                 "visible_alias" => yaml_to_str!(a, v, visible_alias),
@@ -4880,16 +4870,16 @@ mod test {
 
     #[test]
     fn positiona_display_mult() {
-        let p = Arg::new("pos")
-            .index(1)
-            .setting(ArgSettings::MultipleValues);
+        let mut p = Arg::new("pos").index(1);
+        p.set_mut(ArgSettings::MultipleValues);
 
         assert_eq!(&*format!("{}", p), "<pos>...");
     }
 
     #[test]
     fn positional_display_required() {
-        let p2 = Arg::new("pos").index(1).setting(ArgSettings::Required);
+        let mut p2 = Arg::new("pos").index(1);
+        p2.settings.set(ArgSettings::Required);
 
         assert_eq!(&*format!("{}", p2), "<pos>");
     }
@@ -4907,7 +4897,8 @@ mod test {
 
     #[test]
     fn positional_display_val_names_req() {
-        let mut p2 = Arg::new("pos").index(1).setting(ArgSettings::Required);
+        let mut p2 = Arg::new("pos").index(1);
+        p2.settings.set(ArgSettings::Required);
         let mut vm = VecMap::new();
         vm.insert(0, "file1");
         vm.insert(1, "file2");
diff --git a/src/build/macros.rs b/src/build/macros.rs
index 62727c15..ccf5a9e1 100644
--- a/src/build/macros.rs
+++ b/src/build/macros.rs
@@ -178,16 +178,6 @@ macro_rules! yaml_to_bool {
     }};
 }
 
-#[cfg(feature = "yaml")]
-macro_rules! yaml_to_u64 {
-    ($a:ident, $v:ident, $c:ident) => {{
-        $a.$c($v
-            .as_i64()
-            .unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v))
-            as u64)
-    }};
-}
-
 #[cfg(feature = "yaml")]
 macro_rules! yaml_to_usize {
     ($a:ident, $v:ident, $c:ident) => {{
diff --git a/src/build/usage_parser.rs b/src/build/usage_parser.rs
index 102abb5a..e38e16e9 100644
--- a/src/build/usage_parser.rs
+++ b/src/build/usage_parser.rs
@@ -65,13 +65,13 @@ impl<'help> UsageParser<'help> {
             }
         }
         arg.num_vals = if arg.val_names.len() > 1 {
-            Some(arg.val_names.len() as u64)
+            Some(arg.val_names.len())
         } else {
             None
         };
         if !arg.has_switch() && arg.is_set(ArgSettings::MultipleOccurrences) {
             // We had a positional and need to set mult vals too
-            arg.settings.set(ArgSettings::MultipleValues);
+            arg.set_mut(ArgSettings::MultipleValues);
         }
         debug!("UsageParser::parse: vals...{:?}", arg.val_names);
         arg
@@ -87,7 +87,7 @@ impl<'help> UsageParser<'help> {
             == b'<'
             && !self.explicit_name_set
         {
-            arg.settings.set(ArgSettings::Required);
+            arg.set_mut(ArgSettings::Required);
         }
         self.pos += 1;
         self.stop_at(name_end);
@@ -104,7 +104,7 @@ impl<'help> UsageParser<'help> {
         } else {
             debug!("UsageParser::name: setting val name...{}", name);
             if arg.val_names.is_empty() {
-                arg.settings.set(ArgSettings::TakesValue);
+                arg.set_mut(ArgSettings::TakesValue);
             }
             let len = arg.val_names.len();
             arg.val_names.insert(len, name);
@@ -183,9 +183,9 @@ impl<'help> UsageParser<'help> {
             if dot_counter == 3 {
                 debug!("UsageParser::multiple: setting multiple");
                 if arg.is_set(ArgSettings::TakesValue) {
-                    arg.settings.set(ArgSettings::MultipleValues);
+                    arg.set_mut(ArgSettings::MultipleValues);
                 }
-                arg.settings.set(ArgSettings::MultipleOccurrences);
+                arg.set_mut(ArgSettings::MultipleOccurrences);
                 self.prev = UsageToken::Multiple;
                 self.pos += 1;
                 break;
@@ -218,7 +218,7 @@ impl<'help> UsageParser<'help> {
             "UsageParser::default: setting default...\"{}\"",
             &self.usage[self.start..self.pos]
         );
-        arg.settings.set(ArgSettings::TakesValue);
+        arg.set_mut(ArgSettings::TakesValue);
         arg.default_vals = vec![std::ffi::OsStr::new(&self.usage[self.start..self.pos])];
         self.prev = UsageToken::Default;
     }
diff --git a/src/mkeymap.rs b/src/mkeymap.rs
index c1ea6a09..b32b5df9 100644
--- a/src/mkeymap.rs
+++ b/src/mkeymap.rs
@@ -22,7 +22,7 @@ pub(crate) struct MKeyMap<'help> {
 pub(crate) enum KeyType {
     Short(char),
     Long(OsString),
-    Position(u64),
+    Position(usize),
 }
 
 impl KeyType {
@@ -31,8 +31,8 @@ impl KeyType {
     }
 }
 
-impl PartialEq<u64> for KeyType {
-    fn eq(&self, rhs: &u64) -> bool {
+impl PartialEq<usize> for KeyType {
+    fn eq(&self, rhs: &usize) -> bool {
         match self {
             KeyType::Position(x) => x == rhs,
             _ => false,
diff --git a/src/output/usage.rs b/src/output/usage.rs
index 3af10fc7..ee8bb03e 100644
--- a/src/output/usage.rs
+++ b/src/output/usage.rs
@@ -307,7 +307,7 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {
                     }
                 })
                 .max()
-                .unwrap_or_else(|| Some(self.p.app.get_positionals().count() as u64));
+                .unwrap_or_else(|| Some(self.p.app.get_positionals().count()));
             Some(
                 self.p
                     .app
@@ -417,7 +417,7 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {
             .filter(|&pos| incl_last || !pos.is_set(ArgSettings::Last))
             .filter(|pos| !args_in_groups.contains(&pos.id))
             .map(|pos| (pos.index.unwrap(), pos))
-            .collect::<BTreeMap<u64, &Arg>>(); // sort by index
+            .collect::<BTreeMap<usize, &Arg>>(); // sort by index
 
         for p in pmap.values() {
             debug!("Usage::get_required_usage_from:iter:{:?}", p.id);
diff --git a/src/parse/arg_matcher.rs b/src/parse/arg_matcher.rs
index 456fa077..b12c598c 100644
--- a/src/parse/arg_matcher.rs
+++ b/src/parse/arg_matcher.rs
@@ -165,7 +165,7 @@ impl ArgMatcher {
     pub(crate) fn needs_more_vals(&self, o: &Arg) -> bool {
         debug!("ArgMatcher::needs_more_vals: o={}", o.name);
         if let Some(ma) = self.get(&o.id) {
-            let current_num = ma.num_vals_last_group() as u64;
+            let current_num = ma.num_vals_last_group();
             if let Some(num) = o.num_vals {
                 debug!("ArgMatcher::needs_more_vals: num_vals...{}", num);
                 return if o.is_set(ArgSettings::MultipleValues) {
diff --git a/src/parse/errors.rs b/src/parse/errors.rs
index c901f890..f472a984 100644
--- a/src/parse/errors.rs
+++ b/src/parse/errors.rs
@@ -711,7 +711,7 @@ impl Error {
 
     pub(crate) fn too_few_values(
         arg: &Arg,
-        min_vals: u64,
+        min_vals: usize,
         curr_vals: usize,
         usage: String,
         color: ColorChoice,
@@ -764,7 +764,7 @@ impl Error {
 
     pub(crate) fn wrong_number_of_values(
         arg: &Arg,
-        num_vals: u64,
+        num_vals: usize,
         curr_vals: usize,
         usage: String,
         color: ColorChoice,
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index 60038a3c..65db23ab 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -135,7 +135,7 @@ impl<'help, 'app> Parser<'help, 'app> {
 
         //_highest_idx(&self.positionals);
 
-        let num_p = self.app.args.keys().filter(|x| x.is_position()).count() as u64;
+        let num_p = self.app.args.keys().filter(|x| x.is_position()).count();
 
         assert!(
             highest_idx == num_p,
@@ -449,7 +449,7 @@ impl<'help, 'app> Parser<'help, 'app> {
             let low_index_mults = is_second_to_last
                 && self.app.get_positionals().any(|a| {
                     a.is_set(ArgSettings::MultipleValues)
-                        && (positional_count != a.index.unwrap_or(0) as usize)
+                        && (positional_count != a.index.unwrap_or(0))
                 })
                 && self
                     .app
@@ -475,7 +475,7 @@ impl<'help, 'app> Parser<'help, 'app> {
                     needs_val_of = if let Some(p) = self
                         .app
                         .get_positionals()
-                        .find(|p| p.index == Some(pos_counter as u64))
+                        .find(|p| p.index == Some(pos_counter))
                     {
                         ParseResult::Pos(p.id.clone())
                     } else {
@@ -507,7 +507,7 @@ impl<'help, 'app> Parser<'help, 'app> {
                 pos_counter
             };
 
-            if let Some(p) = self.app.args.get(&(pos_counter as u64)) {
+            if let Some(p) = self.app.args.get(&pos_counter) {
                 if p.is_set(ArgSettings::Last) && !self.is_set(AS::TrailingValues) {
                     return Err(ClapError::unknown_argument(
                         arg_os.to_string_lossy().to_string(),
diff --git a/src/parse/validator.rs b/src/parse/validator.rs
index 1e89cc9f..dfc15c42 100644
--- a/src/parse/validator.rs
+++ b/src/parse/validator.rs
@@ -444,9 +444,9 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
         if let Some(num) = a.num_vals {
             debug!("Validator::validate_arg_num_vals: num_vals set...{}", num);
             let should_err = if a.is_set(ArgSettings::MultipleValues) {
-                ((ma.num_vals() as u64) % num) != 0
+                ma.num_vals() % num != 0
             } else {
-                num != (ma.num_vals() as u64)
+                num != ma.num_vals()
             };
             if should_err {
                 debug!("Validator::validate_arg_num_vals: Sending error WrongNumberOfValues");
@@ -454,7 +454,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
                     a,
                     num,
                     if a.is_set(ArgSettings::MultipleValues) {
-                        ma.num_vals() % num as usize
+                        ma.num_vals() % num
                     } else {
                         ma.num_vals()
                     },
@@ -465,7 +465,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
         }
         if let Some(num) = a.max_vals {
             debug!("Validator::validate_arg_num_vals: max_vals set...{}", num);
-            if (ma.num_vals() as u64) > num {
+            if ma.num_vals() > num {
                 debug!("Validator::validate_arg_num_vals: Sending error TooManyValues");
                 return Err(Error::too_many_values(
                     ma.vals_flatten()
@@ -482,7 +482,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
         }
         let min_vals_zero = if let Some(num) = a.min_vals {
             debug!("Validator::validate_arg_num_vals: min_vals set: {}", num);
-            if (ma.num_vals() as u64) < num && num != 0 {
+            if ma.num_vals() < num && num != 0 {
                 debug!("Validator::validate_arg_num_vals: Sending error TooFewValues");
                 return Err(Error::too_few_values(
                     a,


Test patch:
diff --git a/tests/help.rs b/tests/help.rs
index 81827773..ec596a21 100644
--- a/tests/help.rs
+++ b/tests/help.rs
@@ -740,9 +740,11 @@ fn args_with_last_usage() {
         .arg(
             Arg::new("pass through args")
                 .about("Any arguments you wish to pass to the being profiled.")
-                .setting(ArgSettings::MultipleValues)
-                .setting(ArgSettings::MultipleOccurrences)
-                .setting(ArgSettings::Last)
+                .settings(&[
+                    ArgSettings::MultipleValues,
+                    ArgSettings::MultipleOccurrences,
+                    ArgSettings::Last,
+                ])
                 .value_name("ARGS"),
         );
     assert!(utils::compare_output(