Skip to content
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

for index in range() used for iteration over slice #3

Closed
pythonesque opened this issue Nov 19, 2014 · 1 comment
Closed

for index in range() used for iteration over slice #3

pythonesque opened this issue Nov 19, 2014 · 1 comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types

Comments

@pythonesque
Copy link
Contributor

This might have to wait a while, and it might be really hard / impossible to detect, but for a simple loop like this:

let x = something_with_Slice<uint>_implemented;
for i in range(0, n) {
  /*every instance of x is called as x[i], where i is the same immutable uint (*not* MutSlice etc.) */
}

you should just use an iterator.

@jdm
Copy link

jdm commented Nov 19, 2014

Similarly, I've seen

let mut i = 0;
for val in v.iter() {
   //...
   i += 1;
}

which would be better expressed with .iter().enumerate().

@Manishearth Manishearth added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types A-lint Area: New lints labels Aug 11, 2015
birkenfeld added a commit to birkenfeld/rust-clippy that referenced this issue Aug 12, 2015
birkenfeld added a commit to birkenfeld/rust-clippy that referenced this issue Aug 12, 2015
camsteffen added a commit to camsteffen/rust-clippy that referenced this issue Jan 15, 2021
# This is the 1st commit message:

Split filter_map into manual_filter_map

# The commit message rust-lang#2 will be skipped:

# fixup! Split filter_map into manual_filter_map

# The commit message rust-lang#3 will be skipped:

# fixup! Split filter_map into manual_filter_map

# The commit message rust-lang#4 will be skipped:

# fixup! Split filter_map into manual_filter_map

# The commit message rust-lang#5 will be skipped:

# fixup! Split filter_map into manual_filter_map

# The commit message rust-lang#6 will be skipped:

# fixup! Split filter_map into manual_filter_map
@Jarcho Jarcho mentioned this issue Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints 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