Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for RFC #495 (features `slice_patterns` and `advanced_slice_patterns`) #23121
Comments
This comment has been minimized.
This comment has been minimized.
|
triage: P-backcompat-lang (1.0 beta) -- at least for the backwards incompatible parts of rust-lang/rfcs#495. This is something of a nice to have, we can live with it if it doesn't get done. |
rust-highfive
added
the
P-backcompat-lang
label
Mar 6, 2015
rust-highfive
added this to the 1.0 beta milestone
Mar 6, 2015
petrochenkov
referenced this issue
Mar 14, 2015
Merged
Fix binding unsized expressions to ref patterns #23361
This comment has been minimized.
This comment has been minimized.
ghost
commented
Mar 16, 2015
|
I'm on it, by the way. https://github.com/jakub-/rust/tree/array-pattern-changes. I'll open a PR soon. |
bors
added a commit
that referenced
this issue
Mar 22, 2015
This comment has been minimized.
This comment has been minimized.
|
@jakub- go go go! |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
(this is puntable to 1.0 if necessary, but we hope to have it by 1.0 beta.) |
This comment has been minimized.
This comment has been minimized.
|
We are going to feature-gate array patterns, in order to ensure that we can soundly land these changes to the semantics in the future. |
brson
added a commit
to brson/rust
that referenced
this issue
Mar 27, 2015
This comment has been minimized.
This comment has been minimized.
|
Moving off of milestone, since these are now gated. |
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated () |
rust-highfive
added
I-nominated
and removed
P-backcompat-lang
labels
Apr 1, 2015
aturon
removed this from the 1.0 beta milestone
Apr 1, 2015
This comment has been minimized.
This comment has been minimized.
|
P-high, not 1.0. |
pnkfelix
added
P-medium
and removed
I-nominated
labels
Apr 2, 2015
petrochenkov
referenced this issue
Jul 15, 2015
Closed
Rewrite the pattern matching code in trans. #27050
aturon
changed the title
Array pattern adjustments (Tracking issue for RFC #495)
Tracking issue for RFC #495 (features `slice_patterns` and `advanced_slice_patterns`)
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
I've repurposed this as a general tracking issue for the |
This comment has been minimized.
This comment has been minimized.
|
Syntax for named subslice |
This comment has been minimized.
This comment has been minimized.
|
So, once MIR is around, I'll feel much better about this feature from the POV of soundness. It's certainly convenient once in a while. But I have realized a few quirks recently:
|
This comment has been minimized.
This comment has been minimized.
|
It would be also nice to have unnamed
|
This comment has been minimized.
This comment has been minimized.
|
On Thu, Nov 05, 2015 at 12:02:03PM -0800, Vadim Petrochenkov wrote:
I would expect that to produce a |
This comment has been minimized.
This comment has been minimized.
|
I just want matching against constant fixed-length arrays. The .. stuff you can already do with |
This comment has been minimized.
This comment has been minimized.
I could get behind this plan (i.e., no |
nikomatsakis
removed
the
I-nominated
label
Jan 25, 2018
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Feb 17, 2018
•
|
Why not If you have something like Edit: Oh I see, I should've read the full thing. Why not remove the
(Not sure if this has been suggested) |
This comment has been minimized.
This comment has been minimized.
|
#34708 was fixed by @mikhail-m1. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov of what specific subset? If you want to stabilize, can you please open up a new issue that describes the behavior we are stabilizing, giving examples of tests that show how it works? It would be great to also specify what is not being stabilized. Example: #48453 I don't know if there are other bugs, I know that @mikhail-m1 has been working on improving various double-drop bugs and analysis, but I think more for slice patterns. |
This comment has been minimized.
This comment has been minimized.
|
my view of current state
|
This comment has been minimized.
This comment has been minimized.
|
Excellent, looks like there are no codegen issues and no issues that may require breaking backward compatibility in the future. In this case I'll prepare a stabilization PR for slice patterns without |
nikomatsakis
referenced this issue
Mar 8, 2018
Closed
Stabilize fixed-length slice patterns (excluding `..`) #48836
This comment has been minimized.
This comment has been minimized.
|
I just proposed stabilizing the subset without |
petrochenkov
referenced this issue
Mar 9, 2018
Open
Mini-RFC: Finalize syntax for slice patterns with subslices #2359
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this issue
Mar 20, 2018
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Given the mutual impls of It seems too strict to require the pattern to have the same element type as the matched slice. |
This comment has been minimized.
This comment has been minimized.
|
@abonander |
kodabb
pushed a commit
to hedgewars/hw
that referenced
this issue
Jun 27, 2018
dlrobertson
pushed a commit
to dlrobertson/rust
that referenced
this issue
Nov 29, 2018
alexreg
added a commit
to alexreg/rust
that referenced
this issue
Dec 7, 2018
alexreg
added a commit
to alexreg/rust
that referenced
this issue
Dec 7, 2018
alexreg
added a commit
to alexreg/rust
that referenced
this issue
Dec 7, 2018
alexreg
added a commit
to alexreg/rust
that referenced
this issue
Dec 7, 2018
nic-hartley
referenced this issue
Jan 7, 2019
Merged
Use pattern matching in tree traversal (Rust) #573
This comment has been minimized.
This comment has been minimized.
samuela
commented
Mar 16, 2019
|
Any update on this? Being able to pattern match against Vecs and arrays is hugely important for many people coming from functional languages. |
This comment has been minimized.
This comment has been minimized.
|
Rust has had basic slice patterns since 1.26. More advanced patterns are being discussed in rust-lang/rfcs#2359. |
This comment has been minimized.
This comment has been minimized.
samuela
commented
Mar 16, 2019
|
@jethrogb Ah gotcha, what's the current recommended approach to destruct a |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
samuela
commented
Mar 16, 2019
|
@jethrogb Ok, thanks. I'm hoping to be able to match against |
This comment has been minimized.
This comment has been minimized.
|
You can match on |
nikomatsakis commentedMar 6, 2015
•
edited by jonas-schievink
Tracking issue for rust-lang/rfcs#495
Breaking Changes
This RFC is a breaking change for most users of slice patterns. The main change is that slice patterns now have the type
[_]instead of&[_].For example, in the old semantics
the
[a, b..]would have the type&[u8],awould have the typeu8andbthe type&[u8].With the new semantics,
[a, b..]would have the type[u8]andbthe type[u8]- which are the wrong types. To fix that, add a&before the slice and arefbefore the tail as if you were matching a struct (of course, useref mutif you want a mutable reference):Concerns to be resolved before stabilization
History and status