Rust

Rust

Made by DeepSource

Redundant map(..).filter_map(..) chain RS-W1204

Anti-pattern
Minor
Autofix

Using .filter_map(..) with the identity closure after .map(<f>) is equivalent to just .filter_map(<f>), which is both more readable and generally more performant.

Consider using .filter_map(<f>) over .map(<f>).filter_map(|x| x).

Bad practice

let a = ["1", "two", "NaN", "four", "5"];

a.iter()
    .map(|s| s.parse().ok())
    .filter_map(|x| x);

Recommended

let a = ["1", "two", "NaN", "four", "5"];

a.iter().filter_map(|s| s.parse().ok());