-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
RFC: Destructuring vectors syntax #1844
Copy link
Copy link
Closed
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Milestone
Metadata
Metadata
Assignees
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Currently its possible to destructure tuples, records, and enums in let's and alt patterns. It could be useful to also destructure vectors as well, plus it would feel more consistent.
The obvious goal would be to do something like this:
I am not sure of the syntax exactly but it would be useful to be able to destructure vectors at least in some way.
Another example of why this might be useful:
Could be expressed as:
In my samples I am assuming that in this expression:
[head, tail...];headmatches 1 element andtailmatches 0+ elements.But, the difference is just that using pattern matching makes this a lot more readable. If this should apply to lists instead of vectors, let me know, but list's are in the core:: they are in std:: so, my assumption is that it makes more sense for vec to work this way.