sway icon indicating copy to clipboard operation
sway copied to clipboard

Use `while let` in place of `for` in `peekable()` iterations in `sfv2`

Open eureka-cpu opened this issue 2 years ago • 0 comments

let mut value_pairs_iter = value_pairs.iter().enumerate().peekable();
for (var_index, (type_field, comma_token)) in value_pairs_iter.clone() {}

should be:

let mut value_pairs_iter = value_pairs.iter().enumerate().peekable();
while let Some((var_index, (type_field, comma_token))) = value_pairs_iter.next() {}

There are many cases of this in sway-fmt-v2, more examples in #2338 comments

eureka-cpu avatar Aug 09 '22 21:08 eureka-cpu