E1011

E1011#

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.

fn main {
  match Some(1) {
    Some(x) => println(x)
  }
}

Or, you can use is syntax to use this pattern matching as a condition:

fn main {
  if Some(1) is Some(x) {
    println(x)
  }
}

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

fn main {
  match Some(1) {
    Some(x) => println(x)
    _ => println("Other")
  }
}