E0027: Non-Exhaustive Match
Your match expression doesn't cover all possible cases.
Example
enum Color {
Red,
Green,
Blue,
}
fn describe(c: Color) -> i64 {
match c {
Color::Red => { 0 },
Color::Green => { 1 },
// Error: non-exhaustive match, missing: `Color::Blue`
}
}
How to fix
Either handle all variants explicitly:
fn describe(c: Color) -> i64 {
match c {
Color::Red => { 0 },
Color::Green => { 1 },
Color::Blue => { 2 },
}
}
Or use a wildcard pattern to catch remaining cases:
fn describe(c: Color) -> i64 {
match c {
Color::Red => { 0 },
_ => { 1 },
}
}