Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
frewsxcv opened this issue Oct 12, 2015 · 2 comments
Closed

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

frewsxcv opened this issue Oct 12, 2015 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types

Comments

@frewsxcv
Copy link
Member

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);
    }
}
@Manishearth Manishearth added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Oct 12, 2015
@fhartwig
Copy link
Contributor

I'll give this a go.

@Manishearth
Copy link
Member

Let us know if you need help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

3 participants