rust-lang/rust-clippy

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

Open

#4554 aperta il 19 set 2019

Vedi su GitHub
 (12 commenti) (0 reazioni) (1 assegnatario)Rust (1391 fork)batch import
A-lintL-correctnessL-suggestiongood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

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);
    }
}

Guida contributor