-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Warn in cases where enumerate is called, but the enumerated value is ignored (_i)
Categories (optional)
- Kind: I guess "complexity"
What is the advantage of the recommended code over the original code
Removes an unnecessary call, which introduces more code in what could otherwise be a simple for loop.
This can happen if .enumerate() is needed, then in the process of refactoring the index is no longer used - someone might silence the "unused variable warning" by putting an underscore in front of the first item in the tuple (something I think cargo fix will do automatically)
Drawbacks
None.
Example
let things = vec!["a", "b", "c"];
for (_i, item) in things.iter().enumerate() {
}Could be written as:
let things = vec!["a", "b", "c"];
for item in things {
}Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints