1
Fork 0

rustc: Implement pattern matching for structs

This commit is contained in:
Patrick Walton 2012-08-06 17:01:14 -07:00
parent 5cb3a94bfb
commit 253dfc3387
13 changed files with 445 additions and 100 deletions

View file

@ -354,6 +354,16 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
}
pat_rec(fs, etc)
}
pat_struct(pth, fields, etc) => {
let pth_ = fld.fold_path(pth);
let mut fs = ~[];
for fields.each |f| {
vec::push(fs,
{ident: /* FIXME (#2543) */ copy f.ident,
pat: fld.fold_pat(f.pat)});
}
pat_struct(pth_, fs, etc)
}
pat_tup(elts) => pat_tup(vec::map(elts, |x| fld.fold_pat(x))),
pat_box(inner) => pat_box(fld.fold_pat(inner)),
pat_uniq(inner) => pat_uniq(fld.fold_pat(inner)),