Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eureka-cpu opened this issue Aug 9, 2022 · 0 comments · Fixed by #2915
Closed

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

eureka-cpu opened this issue Aug 9, 2022 · 0 comments · Fixed by #2915

Comments

@eureka-cpu
Copy link
Contributor

eureka-cpu commented Aug 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant