Rust

Rust

Made by DeepSource

Found occurrence of .chars().filter(..) RS-W1049

Anti-pattern
Minor

Using .chars().filter(..) requires additional logic and complexity compared to using .matches(..) Using matches(..) allows for much greater flexibility such as using Pattern trait bound types, and matching string expressions directly.

Bad practice

"a b c".chars().filter(|x| *x != ' ').collect::<Vec<char>>();
// ['a', 'b', 'c']

Recommended

"a b c".matches(|x| x != ' ').collect::<Vec<&str>>(); 
// ["a", "b", "c"]