A variant pattern must list one pattern per field of the variant (use _ for fields you don't
need). The message says how many the variant has.
Wrong#
enum Shape { Rect(w: int, h: int) }
fn width(s: Shape): int = match s {
Rect(w) => w
}Fixed#
enum Shape { Rect(w: int, h: int) }
fn width(s: Shape): int = match s {
Rect(w, _) => w
}Common causes#
- A field added to the variant but not to its patterns.
- Matching a variant by name alone:
RectneedsRect(_, _).