Skip to content

Commit 81bc32d

Browse files
committed
doc: Clarified 4.2 Pattern matching
Combined redundant paragraphs about the match expression and removed a redundant example.
1 parent ecc18f3 commit 81bc32d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/doc/tutorial.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,16 @@ Unlike in C, there is no "falling through" between arms: only one arm
468468
executes, and it doesn't have to explicitly `break` out of the
469469
construct when it is finished.
470470

471-
A `match` arm consists of a *pattern*, then an arrow `=>`, followed by
472-
an *action* (expression). Literals are valid patterns and match only
473-
their own value. A single arm may match multiple different patterns by
474-
combining them with the pipe operator (`|`), so long as every pattern
475-
binds the same set of variables. Ranges of numeric literal patterns
476-
can be expressed with two dots, as in `M..N`. The underscore (`_`) is
477-
a wildcard pattern that matches any single value. (`..`) is a different
478-
wildcard that can match one or more fields in an `enum` variant.
479-
480-
The patterns in a match arm are followed by a fat arrow, `=>`, then an
481-
expression to evaluate. Each case is separated by commas. It's often
482-
convenient to use a block expression for each case, in which case the
483-
commas are optional.
471+
A `match` arm consists of a *pattern*, then a fat arrow `=>`, followed
472+
by an *action* (expression). Each case is separated by commas. It is
473+
often convenient to use a block expression for each case, in which case
474+
the commas are optional as shown below. Literals are valid patterns and
475+
match only their own value. A single arm may match multiple different
476+
patterns by combining them with the pipe operator (`|`), so long as every
477+
pattern binds the same set of variables. Ranges of numeric literal
478+
patterns can be expressed with two dots, as in `M..N`. The underscore
479+
(`_`) is a wildcard pattern that matches any single value. (`..`) is a
480+
different wildcard that can match one or more fields in an `enum` variant.
484481

485482
~~~
486483
# let my_number = 1;

0 commit comments

Comments
 (0)