Moved some for loops to more readable iterators

This commit is contained in:
Kevin K 2015-03-18 10:15:55 -04:00
parent bd4de8ff69
commit ff8ea640e9

View file

@ -526,10 +526,13 @@ impl App {
}
if let Some(ref reqs) = v.requires {
if ! reqs.is_empty() {
for n in reqs.iter() {
if matches.opts.contains_key(n) { continue; }
if matches.flags.contains_key(n) { continue; }
if matches.positionals.contains_key(n) { continue; }
// Add all required args which aren't already found in matches to the
// final required list
for n in reqs.iter().filter(|&a|
! matches.opts.contains_key(a) ||
! matches.flags.contains_key(a) ||
! matches.positionals.contains_key(a) ) {
self.required.insert(n);
}
}
@ -744,10 +747,13 @@ impl App {
}
if let Some(ref reqs) = opt.requires {
if ! reqs.is_empty() {
for n in reqs.iter() {
if matches.opts.contains_key(n) { continue; }
if matches.flags.contains_key(n) { continue; }
if matches.positionals.contains_key(n) { continue; }
// Add all required args which aren't already found in matches to the
// final required list
for n in reqs.iter().filter(|&a|
! matches.opts.contains_key(a) ||
! matches.flags.contains_key(a) ||
! matches.positionals.contains_key(a) ) {
self.required.insert(n);
}
}
@ -810,10 +816,13 @@ impl App {
}
if let Some(ref reqs) = p.requires {
if ! reqs.is_empty() {
for n in reqs.iter() {
if matches.opts.contains_key(n) { continue; }
if matches.flags.contains_key(n) { continue; }
if matches.positionals.contains_key(n) { continue; }
// Add all required args which aren't already found in matches to the
// final required list
for n in reqs.iter().filter(|&a|
! matches.opts.contains_key(a) ||
! matches.flags.contains_key(a) ||
! matches.positionals.contains_key(a) ) {
self.required.insert(n);
}
}