From 22000a08f71c2d1f257f345dea41f0ba2aca3d12 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Thu, 10 Mar 2016 16:33:39 -0500 Subject: [PATCH] chore: changes some assertions to debug assertions --- src/app/parser.rs | 10 +++++----- src/usage_parser.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/parser.rs b/src/app/parser.rs index 040d79ea..32bccd14 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -115,7 +115,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b { // actually adds the arguments pub fn add_arg(&mut self, a: &Arg<'a, 'b>) { - assert!(!(self.flags.iter().any(|f| &f.name == &a.name) + debug_assert!(!(self.flags.iter().any(|f| &f.name == &a.name) || self.opts.iter().any(|o| o.name == a.name) || self.positionals.values().any(|p| p.name == a.name)), format!("Non-unique argument name: {} is already in use", a.name)); @@ -124,12 +124,12 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b { ag.args.push(a.name); } if let Some(s) = a.short { - assert!(!self.short_list.contains(&s), + debug_assert!(!self.short_list.contains(&s), format!("Argument short must be unique\n\n\t-{} is already in use", s)); self.short_list.push(s); } if let Some(l) = a.long { - assert!(!self.long_list.contains(&l), + debug_assert!(!self.long_list.contains(&l), format!("Argument long must be unique\n\n\t--{} is already in use", l)); self.long_list.push(l); if l == "help" { @@ -147,7 +147,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b { } else { a.index.unwrap() as usize }; - assert!(!self.positionals.contains_key(i), + debug_assert!(!self.positionals.contains_key(i), format!("Argument \"{}\" has the same index as another positional \ argument\n\n\tPerhaps try .multiple(true) to allow one positional argument \ to take multiple values", a.name)); @@ -175,7 +175,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b { self.flags.push(fb); } if a.is_set(ArgSettings::Global) { - assert!(!a.is_set(ArgSettings::Required), + debug_assert!(!a.is_set(ArgSettings::Required), format!("Global arguments cannot be required.\n\n\t'{}' is marked as global and \ required", a.name)); self.global_args.push(a.into()); diff --git a/src/usage_parser.rs b/src/usage_parser.rs index faaf44c0..782a71c3 100644 --- a/src/usage_parser.rs +++ b/src/usage_parser.rs @@ -61,7 +61,7 @@ impl<'a> UsageParser<'a> { } } else { break; } } - assert!(!arg.name.is_empty(), format!("No name found for Arg when parsing usage string: {}", self.usage)); + debug_assert!(!arg.name.is_empty(), format!("No name found for Arg when parsing usage string: {}", self.usage)); let n_vals = if let Some(ref v) = arg.val_names { v.len() } else { 0 }; if n_vals > 1 { arg.num_vals = Some(n_vals as u64);