Rust

Rust

Made by DeepSource

Iterating over Option type RS-E1004

Bug risk
Critical

Calling .next() on an iterator produces an Option<T>, which also implements IntoIterator. This is probably a mistake, consider revisiting this for loop.

Bad Practice

for x in [1, 2, 3].iter().next() {
    // ...
}

Recommended

// if the intention was to start from the second element,
// consider using `.skip(1)`
for x in [1, 2, 3].iter().skip(1) {
    // ...
}

// or
let mut my_iterator = [1, 2, 3].iter();
let _ = my_iterator.next();

for x in my_iterator {
    // ...
}