mirror of
https://github.com/clap-rs/clap
synced 2025-01-07 10:18:48 +00:00
refactor: Avoid unnecessary uses of enumerate()
.
This commit is contained in:
parent
d8c775eb26
commit
be535e28cf
2 changed files with 2 additions and 15 deletions
|
@ -76,15 +76,7 @@ impl<'a> ArgStr<'a> {
|
||||||
pub(crate) fn trim_start_n_matches(&self, n: usize, ch: u8) -> ArgStr {
|
pub(crate) fn trim_start_n_matches(&self, n: usize, ch: u8) -> ArgStr {
|
||||||
assert!(ch.is_ascii());
|
assert!(ch.is_ascii());
|
||||||
|
|
||||||
let i = self
|
let i = self.0.iter().take(n).take_while(|c| **c == ch).count();
|
||||||
.0
|
|
||||||
.iter()
|
|
||||||
.take(n)
|
|
||||||
.take_while(|c| **c == ch)
|
|
||||||
.enumerate()
|
|
||||||
.last()
|
|
||||||
.map(|(i, _)| i + 1)
|
|
||||||
.unwrap_or(0);
|
|
||||||
|
|
||||||
self.split_at_unchecked(i).1
|
self.split_at_unchecked(i).1
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,7 @@ where
|
||||||
self.0.push(Child::new(req));
|
self.0.push(Child::new(req));
|
||||||
idx
|
idx
|
||||||
} else {
|
} else {
|
||||||
self.0
|
self.0.iter().position(|e| e.id == req).unwrap()
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.find(|(_, e)| e.id == req)
|
|
||||||
.map(|(i, _)| i)
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue