You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clippy reports a while_let_on_iterator with example code that does not compile. Playground link
Original code
letmut slice = [1,2,3,4,5,6,7,8].windows(2);whileletSome([a, b]) = slice.next(){println!("{}, {}", a, b);}
Clippy Error
warning: this loop could be written as a `for` loop
--> src/main.rs:4:30
|
4 | whileletSome([a, b]) = slice.next(){
| ^^^^^^^^^^^^ help:try: `for[a,b] in slice{ .. }`
|
= note: `#[warn(clippy::while_let_on_iterator)]` on by default
= help:for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
Code with clippy solution
letmut slice = [1,2,3,4,5,6,7,8].windows(2);for[a, b]in slice {println!("{}, {}", a, b);}
Compile Error
error[E0005]: refutable pattern in `for` loop binding: `&[]`, `&[_]` and `&[_, _, _, ..]` not covered
--> src/main.rs:10:9
|
10 | for[a, b]in slice {
| ^^^^^^ patterns `&[]`, `&[_]` and `&[_, _, _, ..]` not covered
is_refutable looks buggy. For example, it thinks that a slice pattern is refutable only when it contains a refutable inner pattern. I'll deal with it by the weekends.
Bug
Clippy reports a
while_let_on_iterator
with example code that does not compile. Playground linkOriginal code
Clippy Error
Code with clippy solution
Compile Error
Clippy Version
The text was updated successfully, but these errors were encountered: