Skip to content

Commit 90cd795

Browse files
committed
Update docs to reflect pattern syntax change
1 parent d887c0e commit 90cd795

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

doc/rust.texi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ arbitrary depth.
27022702
A @dfn{declaration statement} is one that introduces a @emph{name} into the
27032703
enclosing statement block. The declared name may denote a new slot or a new
27042704
item. The scope of the name extends to the entire containing block, both
2705-
before and after the declaration.
2705+
before and after the declaration. Tag names may not be shadowed by variable names.
27062706

27072707
@menu
27082708
* Ref.Stmt.Decl.Item:: Statement declaring an item.
@@ -3274,7 +3274,7 @@ alt x @{
32743274
cons(10, _) @{
32753275
process_ten();
32763276
@}
3277-
nil. @{
3277+
nil @{
32783278
ret;
32793279
@}
32803280
_ @{
@@ -3283,12 +3283,6 @@ alt x @{
32833283
@}
32843284
@end example
32853285

3286-
Note in the above example that @code{nil} is followed by a period. This is
3287-
required syntax for pattern matching a nullary tag variant, to distingush the
3288-
variant @code{nil} from a binding to variable @code{nil}. Without the period
3289-
the value of @code{x} would be bound to variable @code{nil} and the compiler
3290-
would issue an error about the final wildcard case being unreachable.
3291-
32923286
Records can also be pattern-matched and their fields bound to variables.
32933287
When matching fields of a record, the fields being matched are specified
32943288
first, then a placeholder (@code{_}) represents the remaining fields.

doc/tutorial/data.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,16 @@ patterns, as in this definition of `area`:
155155
}
156156
}
157157

158-
For variants without arguments, you have to write `variantname.` (with
159-
a dot at the end) to match them in a pattern. This to prevent
160-
ambiguity between matching a variant name and binding a new variable.
158+
Another example:
161159

162160
# type point = {x: float, y: float};
163161
# enum direction { north; east; south; west; }
164162
fn point_from_direction(dir: direction) -> point {
165163
alt dir {
166-
north. { {x: 0f, y: 1f} }
167-
east. { {x: 1f, y: 0f} }
168-
south. { {x: 0f, y: -1f} }
169-
west. { {x: -1f, y: 0f} }
164+
north { {x: 0f, y: 1f} }
165+
east { {x: 1f, y: 0f} }
166+
south { {x: 0f, y: -1f} }
167+
west { {x: -1f, y: 0f} }
170168
}
171169
}
172170

0 commit comments

Comments
 (0)