Implement slicing syntax.

`expr[]`, `expr[expr..]`, `expr[..expr]`,`expr[expr..expr]`

Uses the Slice and SliceMut traits.

Allows ... as well as .. in range patterns.
This commit is contained in:
Nick Cameron
2014-09-15 20:48:58 +12:00
parent af3889f697
commit 31a7e38759
27 changed files with 909 additions and 105 deletions

View File

@@ -1242,6 +1242,12 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
ExprIndex(el, er) => {
ExprIndex(folder.fold_expr(el), folder.fold_expr(er))
}
ExprSlice(e, e1, e2, m) => {
ExprSlice(folder.fold_expr(e),
e1.map(|x| folder.fold_expr(x)),
e2.map(|x| folder.fold_expr(x)),
m)
}
ExprPath(pth) => ExprPath(folder.fold_path(pth)),
ExprBreak(opt_ident) => ExprBreak(opt_ident.map(|x| folder.fold_ident(x))),
ExprAgain(opt_ident) => ExprAgain(opt_ident.map(|x| folder.fold_ident(x))),