blob: 6fb315a371655984d7d5bfb00a8bf856b0520079 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
Pattern arm did not match expected kind.
Erroneous code example:
```compile_fail,E0532
enum State {
Succeeded,
Failed(String),
}
fn print_on_failure(state: &State) {
match *state {
// error: expected unit struct, unit variant or constant, found tuple
// variant `State::Failed`
State::Failed => println!("Failed"),
_ => ()
}
}
```
To fix this error, ensure the match arm kind is the same as the expression
matched.
Fixed example:
```
enum State {
Succeeded,
Failed(String),
}
fn print_on_failure(state: &State) {
match *state {
State::Failed(ref msg) => println!("Failed with {}", msg),
_ => ()
}
}
```
|