E0011#
Warning name: partial_match
Partial match. The match/guard/loop expression does not cover all possible cases.
Erroneous example#
///|
fn main {
match Some(1) { // Partial match, some hints: None
Some(x) => println(x)
}
}
Suggestion#
The warning message usually contains hints about the missing patterns. Add the missing cases to avoid incomplete matches. You can use quick fix when using VSCode Plugin.
///|
fn main {
match Some(1) {
Some(x) => println(x)
None => println("None")
}
}
Or, you can use is syntax to use this pattern matching as a condition:
///|
/// Example using `is` syntax for conditional pattern matching
pub fn example_with_is() -> Unit {
if Some(1) is Some(x) {
println(x)
}
}
Or, you can add a wildcard pattern to catch all remaining cases:
///|
/// Example using wildcard pattern to catch all remaining cases
pub fn example_with_wildcard() -> Unit {
match Some(1) {
Some(x) => println(x)
_ => println("Other")
}
}