]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/match_ref_pats.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / match_ref_pats.txt
1 ### What it does
2 Checks for matches where all arms match a reference,
3 suggesting to remove the reference and deref the matched expression
4 instead. It also checks for `if let &foo = bar` blocks.
5
6 ### Why is this bad?
7 It just makes the code less readable. That reference
8 destructuring adds nothing to the code.
9
10 ### Example
11 ```
12 match x {
13     &A(ref y) => foo(y),
14     &B => bar(),
15     _ => frob(&x),
16 }
17 ```
18
19 Use instead:
20 ```
21 match *x {
22     A(ref y) => foo(y),
23     B => bar(),
24     _ => frob(x),
25 }
26 ```