rust-lang/rust-clippy

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

Open

#4.554 aberto em 19 de set. de 2019

Ver no GitHub
 (12 comments) (0 reactions) (1 assignee)Rust (1.391 forks)batch import
A-lintL-correctnessL-suggestiongood first issue

Métricas do repositório

Stars
 (10.406 stars)
Métricas de merge de PR
 (Mesclagem média 19d 22h) (113 fundiu PRs em 30d)

Description

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

Guia do colaborador