]> git.lizzy.rs Git - rust.git/blob - src/docs/unneeded_field_pattern.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / unneeded_field_pattern.txt
1 ### What it does
2 Checks for structure field patterns bound to wildcards.
3
4 ### Why is this bad?
5 Using `..` instead is shorter and leaves the focus on
6 the fields that are actually bound.
7
8 ### Example
9 ```
10 let f = Foo { a: 0, b: 0, c: 0 };
11
12 match f {
13     Foo { a: _, b: 0, .. } => {},
14     Foo { a: _, b: _, c: _ } => {},
15 }
16 ```
17
18 Use instead:
19 ```
20 let f = Foo { a: 0, b: 0, c: 0 };
21
22 match f {
23     Foo { b: 0, .. } => {},
24     Foo { .. } => {},
25 }
26 ```