@@ -110,17 +110,30 @@ match &mut v {
110110[ reference-level-explanation ] : #reference-level-explanation
111111
112112` .. ` can be used as a pattern fragment for matching sub-slices and sub-arrays.
113- It is treated as a "non-reference-pattern" for the purpose of determining default-binding-modes,
114- and so shifts the binding mode to by-` ref ` or by-` ref mut ` when used to match a subsection of a
115- reference or mutable reference to a slice or array.
113+
114+ The fragment's syntax is:
115+ ```
116+ SUBSLICE = .. | BINDING @ ..
117+ BINDING = ref? mut? IDENT
118+ ```
119+
120+ The subslice fragment incorporates into the full subslice syntax in the same way as the ` .. `
121+ fragment incorporates into the stable tuple pattern syntax (with regards to allowed number of
122+ subslices, trailing commas, etc).
116123
117124` @ ` can be used to bind the result of ` .. ` to an identifier.
118125
126+ ` .. ` is treated as a "non-reference-pattern" for the purpose of determining default-binding-modes,
127+ and so shifts the binding mode to by-` ref ` or by-` ref mut ` when used to match a subsection of a
128+ reference or mutable reference to a slice or array.
129+
119130When used to match against a non-reference slice (` [u8] ` ), ` x @ .. ` would attempt to bind
120131by-value, which would fail due a move from a non-copy type ` [u8] ` .
121132
122- ` .. ` / ` IDENT @ .. ` is not a full pattern syntax, but rather a part of slice, tuple and tuple
133+ ` .. ` is not a full pattern syntax, but rather a part of slice, tuple and tuple
123134struct pattern syntaxes. In particular, ` .. ` is not accepted by the ` pat ` macro matcher.
135+ ` BINDING @ .. ` is also not a full pattern syntax, but rather a part of slice pattern syntax, so
136+ it is not accepted by the ` pat ` macro matcher either.
124137
125138# Drawbacks
126139[ drawbacks ] : #drawbacks
@@ -209,8 +222,7 @@ range pattern, then it means that we consumed too much and need to reinterpret t
209222somehow. It's probably possible to make this work, but it's some headache that we would like to
210223avoid if possible.
211224
212- This RFC no longer includes the addition of ` ..PAT ` or ` PAT.. ` , but merely ` .. ` as it results in
213- a smaller starting surface-area for the feature which can be expanded in the future if necessary.
225+ This RFC no longer includes the addition of ` ..PAT ` or ` PAT.. ` .
214226The currently-proposed change is a minimal addition to patterns (` .. ` for slices) which
215227already exists in other forms (e.g. tuples) and generalizes well to pattern-matching out sub-tuples,
216228e.g. ` let (a, b @ .., c) = (1, 2, 3, 4); ` .
0 commit comments