Skip to main content

E0056: Pattern Tuple Mismatch

A tuple pattern's shape doesn't match the type of the value being matched. Either the value is not a tuple, or the pattern has a different number of elements than the tuple type.

Example

fn first(pair: (i64, bool)) -> i64 {
match pair {
(a, b, c) => { a }, // Error: pattern expects a tuple with 3 elements but scrutinee has type `(i64, bool)`
}
}

How to fix

Use a tuple pattern with the same number of elements as the tuple type:

fn first(pair: (i64, bool)) -> i64 {
match pair {
(a, b) => { a },
}
}