rust-lang/rust-clippy

New lint: `while let Some(&x) = slice.iter().next()` is infinite loop

Open

#4,554 opened on 2019年9月19日

GitHub で見る
 (12 comments) (0 reactions) (1 assignee)Rust (1,391 forks)batch import
A-lintL-correctnessL-suggestiongood first issue

Repository metrics

Stars
 (10,406 stars)
PR merge metrics
 (平均マージ 19d 22h) (30d で 113 merged PRs)

説明

This code is an infinite loop: (Do not run this in playpen)

fn main() {
    let a = [1, 2, 3];
    while let Some(&x) = a.iter().next() {
        println!("{:?}", x);
    }
}

コントリビューターガイド