never_loop in for loop #7537
Labels
good-first-issue
These issues are a good way to get started with Clippy
L-suggestion
Lint: Improving, adding or fixing lint suggestions
People use a never_loop for loop for picking first element (if exists) of an iterator. It is possible without such a loop with
if let Some(elem) = x.iter().next() {
instead offor elem in x {
but is it considered a better way? If it isn't, we should disable never_loop forfor
loops. If it is, we can provide a auto-fix suggestion so people who are not aware of this, don't disable lint.The text was updated successfully, but these errors were encountered: