Use simple 'for i in x' loops instead of 'while let Some(x) = x.next()' loops on iterators. (clippy::while_let_on_iterator)

This commit is contained in:
Matthias Krüger 2020-03-05 13:20:04 +01:00
parent c2bbe3349f
commit 3e70c8ec2f
2 changed files with 4 additions and 9 deletions

View File

@ -311,9 +311,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// taking into account the `spread_arg`. If we could write
// this is a single iterator (that handles `spread_arg`), then
// `pass_argument` would be the loop body. It takes care to
// not advance `caller_iter` for ZSTs.
let mut locals_iter = body.args_iter();
while let Some(local) = locals_iter.next() {
// not advance `caller_iter` for ZSTs
for local in body.args_iter() {
let dest = self.eval_place(&mir::Place::from(local))?;
if Some(local) == body.spread_arg {
// Must be a tuple

View File

@ -869,12 +869,8 @@ pub fn plain_summary_line(md: &str) -> String {
}
}
let mut s = String::with_capacity(md.len() * 3 / 2);
let mut p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
while let Some(t) = p.next() {
if !t.is_empty() {
s.push_str(&t);
}
}
let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
p.into_iter().filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
s
}