We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba1df0e commit 6afecc3Copy full SHA for 6afecc3
doc/rust.texi
@@ -3396,12 +3396,21 @@ alt x @{
3396
cons(10, _) @{
3397
process_ten();
3398
@}
3399
+ nil. @{
3400
+ ret;
3401
+ @}
3402
_ @{
3403
fail;
3404
3405
3406
@end example
3407
3408
+Note in the above example that @code{nil} is followed by a period. This is
3409
+required syntax for pattern matching a nullary tag variant, to distingush the
3410
+variant @code{nil} from a binding to variable @code{nil}. Without the period
3411
+the value of @code{x} would be bound to variable @code{nil} and the compiler
3412
+would issue an error about the final wildcard case being unreachable.
3413
+
3414
Multiple alternative patterns may be joined with the @code{|} operator. A
3415
range of values may be specified with @code{to}. For example:
3416
0 commit comments