Clean up E0164 explanation
This commit is contained in:
parent
ec64bbbe07
commit
aab4276477
1 changed files with 29 additions and 9 deletions
|
|
@ -1,24 +1,44 @@
|
|||
This error means that an attempt was made to match a struct type enum
|
||||
variant as a non-struct type:
|
||||
Something which is neither a tuple struct nor a tuple variant was used as a
|
||||
pattern.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0164
|
||||
enum Foo { B { i: u32 } }
|
||||
enum A {
|
||||
B,
|
||||
C,
|
||||
}
|
||||
|
||||
fn bar(foo: Foo) -> u32 {
|
||||
impl A {
|
||||
fn new() {}
|
||||
}
|
||||
|
||||
fn bar(foo: A) {
|
||||
match foo {
|
||||
Foo::B(i) => i, // error E0164
|
||||
A::new() => (), // error!
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Try using `{}` instead:
|
||||
This error means that an attempt was made to match something which is neither a
|
||||
tuple struct nor a tuple variant. Only these two elements are allowed as
|
||||
pattern:
|
||||
|
||||
```
|
||||
enum Foo { B { i: u32 } }
|
||||
enum A {
|
||||
B,
|
||||
C,
|
||||
}
|
||||
|
||||
fn bar(foo: Foo) -> u32 {
|
||||
impl A {
|
||||
fn new() {}
|
||||
}
|
||||
|
||||
fn bar(foo: A) {
|
||||
match foo {
|
||||
Foo::B{i} => i,
|
||||
A::B => (), // ok!
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue