Allow binding of nested patterns

See src/test/run-pass/nested-patterns.rs for some examples. The syntax is

    boundvar@subpattern

Which will match the subpattern as usual, but also bind boundvar to the
whole matched value.

Closes #838
This commit is contained in:
Marijn Haverbeke 2011-12-08 11:56:16 +01:00
parent 8c966b7b18
commit 9a269a3aa8
17 changed files with 132 additions and 79 deletions

View file

@ -92,7 +92,7 @@ type field_pat = {ident: ident, pat: @pat};
tag pat_ {
pat_wild;
pat_bind(ident);
pat_bind(ident, option::t<@pat>);
pat_tag(@path, [@pat]);
pat_rec([field_pat], bool);
pat_tup([@pat]);