]>
Commit | Line | Data |
---|---|---|
dfeec247 XL |
1 | Something which is neither a tuple struct nor a tuple variant was used as a |
2 | pattern. | |
3 | ||
4 | Erroneous code example: | |
60c5eb7d XL |
5 | |
6 | ```compile_fail,E0164 | |
dfeec247 XL |
7 | enum A { |
8 | B, | |
9 | C, | |
10 | } | |
11 | ||
12 | impl A { | |
13 | fn new() {} | |
14 | } | |
60c5eb7d | 15 | |
dfeec247 | 16 | fn bar(foo: A) { |
60c5eb7d | 17 | match foo { |
dfeec247 XL |
18 | A::new() => (), // error! |
19 | _ => {} | |
60c5eb7d XL |
20 | } |
21 | } | |
22 | ``` | |
23 | ||
dfeec247 XL |
24 | This error means that an attempt was made to match something which is neither a |
25 | tuple struct nor a tuple variant. Only these two elements are allowed as a | |
26 | pattern: | |
60c5eb7d XL |
27 | |
28 | ``` | |
dfeec247 XL |
29 | enum A { |
30 | B, | |
31 | C, | |
32 | } | |
33 | ||
34 | impl A { | |
35 | fn new() {} | |
36 | } | |
60c5eb7d | 37 | |
dfeec247 | 38 | fn bar(foo: A) { |
60c5eb7d | 39 | match foo { |
dfeec247 XL |
40 | A::B => (), // ok! |
41 | _ => {} | |
60c5eb7d XL |
42 | } |
43 | } | |
44 | ``` |