E0011

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 (1) {
    () => ()
     => ("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 () ->  {
  if (1) is () {
    ()
  }
}

Or, you can add a wildcard pattern to catch all remaining cases:

///|
/// Example using wildcard pattern to catch all remaining cases
pub fn () ->  {
  match (1) {
    () => ()
    _ => ("Other")
  }
}