dylint

suboptimal_pattern

What it does

Checks for patterns that could perform additional destructuring.

Why is this bad?

The use of destructuring patterns in closure parameters (for example) often leads to more concise closure bodies. Beyond that, the benefits of this lint are similar to those of pattern-type-mismatch.

Known problems

Example

let xs = [0, 1, 2];
let ys = xs.iter().map(|x| *x == 0).collect::<Vec<_>>();

Use instead:

let xs = [0, 1, 2];
let ys = xs.iter().map(|&x| x == 0).collect::<Vec<_>>();

Configuration