File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 93035722a47915793c75af79af8f39c9840a78c0
2
+ refs/heads/master: 151aaf84ce5b4838f6d1be014681b3135a69b5db
Original file line number Diff line number Diff line change @@ -676,6 +676,7 @@ The keywords are:
676
676
@tab @code {fail }
677
677
@tab @code {ret }
678
678
@tab @code {be }
679
+ @item @code {when }
679
680
@end multitable
680
681
681
682
@node Ref.Lex.Res
@@ -3361,6 +3362,18 @@ let message = alt x @{
3361
3362
@}
3362
3363
@end example
3363
3364
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
+
3364
3377
3365
3378
@node Ref.Expr.Alt.Type
3366
3379
@subsubsection Ref.Expr.Alt.Type
You can’t perform that action at this time.
0 commit comments