Skip to content

Commit c6538f2

Browse files
committed
---
yaml --- r: 6067 b: refs/heads/master c: 151aaf8 h: refs/heads/master i: 6065: fce5bb3 6063: a7b6461 v: v3
1 parent 81dde25 commit c6538f2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 93035722a47915793c75af79af8f39c9840a78c0
2+
refs/heads/master: 151aaf84ce5b4838f6d1be014681b3135a69b5db

trunk/doc/rust.texi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ The keywords are:
676676
@tab @code{fail}
677677
@tab @code{ret}
678678
@tab @code{be}
679+
@item @code{when}
679680
@end multitable
680681

681682
@node Ref.Lex.Res
@@ -3361,6 +3362,18 @@ let message = alt x @{
33613362
@}
33623363
@end example
33633364

3365+
Finally, alt patterns can accept @emph{pattern guards} to further refine the
3366+
criteria for matching a case. Pattern guards appear after the pattern and
3367+
consist of a bool-typed expression following the @emph{when} keyword. A pattern
3368+
guard may refer to the variables bound within the pattern they follow.
3369+
3370+
@example
3371+
let message = alt maybe_digit @{
3372+
some(x) when x < 10 @{ process_digit(x) @}
3373+
some(x) @{ process_other(x) @}
3374+
@}
3375+
@end example
3376+
33643377

33653378
@node Ref.Expr.Alt.Type
33663379
@subsubsection Ref.Expr.Alt.Type

0 commit comments

Comments
 (0)