mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
Merge #1735
1735: Get rid of extra scopes r=pksunkara a=CreepySkeleton Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
This commit is contained in:
commit
bc738e12c2
3 changed files with 23 additions and 30 deletions
|
@ -1408,12 +1408,9 @@ impl<'b> App<'b> {
|
|||
self._build();
|
||||
}
|
||||
|
||||
{
|
||||
let mut parser = Parser::new(self);
|
||||
|
||||
// do the real parsing
|
||||
parser.get_matches_with(&mut matcher, it)?;
|
||||
}
|
||||
// do the real parsing
|
||||
let mut parser = Parser::new(self);
|
||||
parser.get_matches_with(&mut matcher, it)?;
|
||||
|
||||
let global_arg_vec: Vec<Id> = self
|
||||
.args
|
||||
|
@ -1438,13 +1435,12 @@ impl<'b> App<'b> {
|
|||
|
||||
self._derive_display_order();
|
||||
self._create_help_and_version();
|
||||
|
||||
// Perform expensive debug assertions
|
||||
debug_assert!({
|
||||
for a in self.args.args.iter() {
|
||||
self._arg_debug_asserts(a);
|
||||
}
|
||||
true
|
||||
});
|
||||
#[cfg(debug_assertions)]
|
||||
for a in self.args.args.iter() {
|
||||
self._arg_debug_asserts(a);
|
||||
}
|
||||
|
||||
let mut pos_counter = 1;
|
||||
for a in self.args.args.iter_mut() {
|
||||
|
|
|
@ -153,22 +153,20 @@ impl<'b> MKeyMap<'b> {
|
|||
let positional;
|
||||
let mut longs: Vec<_>;
|
||||
|
||||
{
|
||||
let arg = &self.args[index];
|
||||
short = arg.short.map(KeyType::Short);
|
||||
positional = arg.index.map(KeyType::Position);
|
||||
let arg = &self.args[index];
|
||||
short = arg.short.map(KeyType::Short);
|
||||
positional = arg.index.map(KeyType::Position);
|
||||
|
||||
longs = arg
|
||||
.aliases
|
||||
.clone()
|
||||
.map(|v| {
|
||||
v.iter()
|
||||
.map(|(n, _)| KeyType::Long(OsString::from(n)))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
longs.extend(arg.long.map(|l| KeyType::Long(OsString::from(l))));
|
||||
}
|
||||
longs = arg
|
||||
.aliases
|
||||
.clone()
|
||||
.map(|v| {
|
||||
v.iter()
|
||||
.map(|(n, _)| KeyType::Long(OsString::from(n)))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
longs.extend(arg.long.map(|l| KeyType::Long(OsString::from(l))));
|
||||
|
||||
if let Some(s) = short {
|
||||
self.insert_key(s, index)
|
||||
|
|
|
@ -41,9 +41,8 @@ impl<'b, 'c, 'z> Validator<'b, 'c, 'z> {
|
|||
self.p.add_defaults(matcher)?;
|
||||
if let ParseResult::Opt(a) = needs_val_of {
|
||||
debugln!("Validator::validate: needs_val_of={:?}", a);
|
||||
{
|
||||
self.validate_required(matcher)?;
|
||||
}
|
||||
self.validate_required(matcher)?;
|
||||
|
||||
let o = self.p.app.find(a).expect(INTERNAL_ERROR_MSG);
|
||||
reqs_validated = true;
|
||||
let should_err = if let Some(v) = matcher.0.args.get(&o.id) {
|
||||
|
|
Loading…
Reference in a new issue