@@ -31,27 +31,23 @@ You may also be interested in the [grammar].
31
31
32
32
## Unicode productions
33
33
34
- A few productions in Rust's grammar permit Unicode code points outside the
35
- ASCII range. We define these productions in terms of character properties
36
- specified in the Unicode standard, rather than in terms of ASCII-range code
37
- points. The grammar has a [ Special Unicode Productions] [ unicodeproductions ]
38
- section that lists these productions.
39
-
40
- [ unicodeproductions ] : grammar.html#special-unicode-productions
34
+ A few productions in Rust's grammar permit Unicode code points outside the ASCII
35
+ range. We define these productions in terms of character properties specified
36
+ in the Unicode standard, rather than in terms of ASCII-range code points. The
37
+ section [ Special Unicode Productions] ( #special-unicode-productions ) lists these
38
+ productions.
41
39
42
40
## String table productions
43
41
44
42
Some rules in the grammar &mdash ; notably [ unary
45
43
operators] ( #unary-operator-expressions ) , [ binary
46
- operators] ( #binary-operator-expressions ) , and [ keywords] [ keywords ] &mdash ; are
44
+ operators] ( #binary-operator-expressions ) , and [ keywords] ( # keywords) &mdash ; are
47
45
given in a simplified form: as a listing of a table of unquoted, printable
48
46
whitespace-separated strings. These cases form a subset of the rules regarding
49
47
the [ token] ( #tokens ) rule, and are assumed to be the result of a
50
48
lexical-analysis phase feeding the parser, driven by a DFA, operating over the
51
49
disjunction of all such string table entries.
52
50
53
- [ keywords ] : grammar.html#keywords
54
-
55
51
When such a string enclosed in double-quotes (` " ` ) occurs inside the grammar,
56
52
it is an implicit reference to a single member of such a string table
57
53
production. See [ tokens] ( #tokens ) for more information.
@@ -79,7 +75,7 @@ An identifier is any nonempty Unicode[^non_ascii_idents] string of the following
79
75
- The first character has property ` XID_start `
80
76
- The remaining characters have property ` XID_continue `
81
77
82
- that does _ not_ occur in the set of [ keywords] [ keywords ] .
78
+ that does _ not_ occur in the set of [ keywords] ( # keywords) .
83
79
84
80
> ** Note** : ` XID_start ` and ` XID_continue ` as character properties cover the
85
81
> character ranges used to form the more familiar C and Java language-family
@@ -405,7 +401,7 @@ Symbols are a general class of printable [token](#tokens) that play structural
405
401
roles in a variety of grammar productions. They are catalogued here for
406
402
completeness as the set of remaining miscellaneous printable tokens that do not
407
403
otherwise appear as [ unary operators] ( #unary-operator-expressions ) , [ binary
408
- operators] ( #binary-operator-expressions ) , or [ keywords] [ keywords ] .
404
+ operators] ( #binary-operator-expressions ) , or [ keywords] ( # keywords) .
409
405
410
406
411
407
## Paths
@@ -551,7 +547,7 @@ _name_ s that occur in its body. At the "current layer", they all must repeat
551
547
the same number of times, so ` ( $( $i: ident ),* ; $( $j: ident ),* ) => ( $(
552
548
($i,$j) ),* )` is valid if given the argument ` (a,b,c ; d,e,f)`, but not
553
549
` (a,b,c ; d,e) ` . The repetition walks through the choices at that layer in
554
- lockstep, so the former input transcribes to ` (a,d), (b,e), (c,f) ` .
550
+ lockstep, so the former input transcribes to ` ( ( a,d), (b,e), (c,f) ) ` .
555
551
556
552
Nested repetitions are allowed.
557
553
@@ -615,7 +611,7 @@ module needs its own source file: [module definitions](#modules) can be nested
615
611
within one file.
616
612
617
613
Each source file contains a sequence of zero or more ` item ` definitions, and
618
- may optionally begin with any number of [ attributes] ( #items- and- attributes )
614
+ may optionally begin with any number of [ attributes] (#Items and attributes)
619
615
that apply to the containing module, most of which influence the behavior of
620
616
the compiler. The anonymous crate module can have additional attributes that
621
617
apply to the crate as a whole.
@@ -657,7 +653,7 @@ There are several kinds of item:
657
653
* [ ` use ` declarations] ( #use-declarations )
658
654
* [ modules] ( #modules )
659
655
* [ functions] ( #functions )
660
- * [ type definitions ] ( grammar.html #type-definitions )
656
+ * [ type aliases ] ( #type-aliases )
661
657
* [ structures] ( #structures )
662
658
* [ enumerations] ( #enumerations )
663
659
* [ constant items] ( #constant-items )
@@ -777,7 +773,7 @@ extern crate std as ruststd; // linking to 'std' under another name
777
773
A _ use declaration_ creates one or more local name bindings synonymous with
778
774
some other [ path] ( #paths ) . Usually a ` use ` declaration is used to shorten the
779
775
path required to refer to a module item. These declarations may appear at the
780
- top of [ modules] ( #modules ) and [ blocks] ( grammar.html#block-expressions ) .
776
+ top of [ modules] ( #modules ) and [ blocks] ( #blocks ) .
781
777
782
778
> ** Note** : Unlike in many languages,
783
779
> ` use ` declarations in Rust do * not* declare linkage dependency with external crates.
@@ -1148,7 +1144,9 @@ let px: i32 = match p { Point(x, _) => x };
1148
1144
```
1149
1145
1150
1146
A _ unit-like struct_ is a structure without any fields, defined by leaving off
1151
- the list of fields entirely. Such types will have a single value. For example:
1147
+ the list of fields entirely. Such types will have a single value, just like
1148
+ the [ unit value ` () ` ] ( #unit-and-boolean-literals ) of the unit type. For
1149
+ example:
1152
1150
1153
1151
```
1154
1152
struct Cookie;
@@ -2438,6 +2436,11 @@ comma:
2438
2436
(0); // zero in parentheses
2439
2437
```
2440
2438
2439
+ ### Unit expressions
2440
+
2441
+ The expression ` () ` denotes the _ unit value_ , the only value of the type with
2442
+ the same name.
2443
+
2441
2444
### Structure expressions
2442
2445
2443
2446
There are several forms of structure expressions. A _ structure expression_
@@ -3278,7 +3281,7 @@ constructor or `struct` field may refer, directly or indirectly, to the
3278
3281
enclosing ` enum ` or ` struct ` type itself. Such recursion has restrictions:
3279
3282
3280
3283
* Recursive types must include a nominal type in the recursion
3281
- (not mere [ type definitions] ( grammar.html #type-definitions) ,
3284
+ (not mere [ type definitions] ( #type-definitions ) ,
3282
3285
or other structural types such as [ arrays] ( #array,-and-slice-types ) or [ tuples] ( #tuple-types ) ).
3283
3286
* A recursive ` enum ` item must have at least one non-recursive constructor
3284
3287
(in order to give the recursion a basis case).
0 commit comments