A struct pattern lists every field, or ends with .. to say "and the others don't matter".
This way adding a field to a struct makes you revisit each pattern that names its fields.
Wrong#
struct P { x: int, y: int }
fn getx(p: P): int = match p {
P { x } => x
}Fixed#
struct P { x: int, y: int }
fn getx(p: P): int = match p {
P { x, .. } => x
}Common causes#
- Leaving out the
..when only some fields are needed. - A field added to the struct after the pattern was written.