Checks for patterns that could perform additional destructuring.
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.
ref
annotations.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<_>>();
explicit_deref_check: bool
(default true
): By default, suboptimal_pattern
will not
suggest to destructure a reference unless it would eliminate at least one explicit
dereference. Setting explicit_deref_check
to false
disables this check.