Skip to content

Suggest for loop over while let when looping over iterator #387

@frewsxcv

Description

@frewsxcv

If someone does this:

#![feature(plugin)]

#![plugin(clippy)]


fn some_function() {
    let mut some_iterator = 1..20;
    while let Some(x) = some_iterator.next() {
        println!("{}", x);
    }
}

suggest doing this:

#![feature(plugin)]

#![plugin(clippy)]


fn some_function() {
    let mut some_iterator = 1..20;
    for x in some_iterator {
        println!("{}", x);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions