mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +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 {
|
||||
assert!(ch.is_ascii());
|
||||
|
||||
let i = self
|
||||
.0
|
||||
.iter()
|
||||
.take(n)
|
||||
.take_while(|c| **c == ch)
|
||||
.enumerate()
|
||||
.last()
|
||||
.map(|(i, _)| i + 1)
|
||||
.unwrap_or(0);
|
||||
let i = self.0.iter().take(n).take_while(|c| **c == ch).count();
|
||||
|
||||
self.split_at_unchecked(i).1
|
||||
}
|
||||
|
|
|
@ -30,12 +30,7 @@ where
|
|||
self.0.push(Child::new(req));
|
||||
idx
|
||||
} else {
|
||||
self.0
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, e)| e.id == req)
|
||||
.map(|(i, _)| i)
|
||||
.unwrap()
|
||||
self.0.iter().position(|e| e.id == req).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue