Rust

Rust

By DeepSource

Found manual implementation of find_map RS-W1210

Anti-pattern Autofix

Using filter_map(<f>).next() is equivalent to using find_map(<f>).

Consider using find_map(..) over filter_map(..).next().

Bad practice

let t = ["2A", "3", "4B", "5"];
let n = t.iter().filter_map(|x| x.parse::<i32>().ok()).next();

Recommended

let t = ["2A", "3", "4B", "5"];
let n = t.iter().find_map(|x| x.parse::<i32>().ok());