E::V(..) Matches All of a Variant’s ValuesStatus: Accepted
Date: October 14, 2026
Answers: whether a pattern can match a variant without naming each of the
values it carries
Related:
ADR-291 D10, D17 (the shapes of a pattern, _ as a part);
Part I 3.4; Part III 17.1
Does a pattern that only asks which variant have to name every value?
Held::Precondition(_, _, _) writes one _ per value, and changes with every
value the variant gains or loses, though the arm reads none of them. A struct
pattern already has .. for the rest of the fields,
Event::Click(Point { x, .. }).
E::V(..) matches the variant whatever values it carries... alone in a variant’s brackets stands for all of its values and binds
none. It lowers to Rust’s E::V(..). A match that names E::V(..) covers
E::V as E::V(_, _, _) would.
Why. It is the struct pattern’s .. applied to a variant: one spelling,
one meaning, the rest. The arm states that it reads nothing, and it stays
valid when the variant’s values change, which is the arm’s intent. Rust,
Swift (case .v) and OCaml (V _) each give a variant a pattern that ignores
its whole payload.
E::V(..) is refused: NK1255.There is nothing for the rest to stand for; the pattern is E::V.
E::V(a, ..) and (a, ..) (the first values, then the rest) are not part of
the language. They parse and are refused with NK1255, whose message says
so, rather than as a syntax error. Whether a positional rest is added is left
open; nothing here argues against it.
Changed by ADR-355 D3: a positional .. is the remaining
values, as in a list pattern; NK1255 stays only for .. on a variant
without values.
E::V without brackets matching any payload. The reader cannot tell
from the arm whether the variant carries values, and an arm written for a
unit variant would go on matching silently after the variant gains values,
where the language otherwise shows every site that has to know._ per value
and breaks at each change of the variant; a converter from Rust cannot
write the _s without the type.