ADR-349: E::V(..) Matches All of a Variant’s Values

Status: 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

1. Question

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, .. }).

2. Decisions

D1 — 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.

D2 — On a variant without values, E::V(..) is refused: NK1255.

There is nothing for the rest to stand for; the pattern is E::V.

D3 — A positional rest is not decided.

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.

3. Rejected alternatives

This site is open source. Improve this page.