@@ -79,17 +79,17 @@ Here are some examples:
7979
8080### Moved and copied types
8181
82- When a [ local variable] ( # variables) is used as an
83- [ rvalue] ( #lvalues-rvalues-and-temporaries ) , the variable will be copied
84- if its type implements ` Copy ` . All others are moved.
82+ When a [ local variable] ( variables.html ) is used as an
83+ [ rvalue] ( expressions.html #lvalues-rvalues-and-temporaries) , the variable will
84+ be copied if its type implements ` Copy ` . All others are moved.
8585
8686## Literal expressions
8787
88- A _ literal expression_ consists of one of the [ literal] ( #literals ) forms
88+ A _ literal expression_ consists of one of the [ literal] ( tokens.md #literals) forms
8989described earlier. It directly describes a number, character, string, boolean
9090value, or the unit value.
9191
92- ``` {.literals}
92+ ``` text
9393(); // unit type
9494"hello"; // string type
9595'5'; // character type
@@ -98,13 +98,15 @@ value, or the unit value.
9898
9999## Path expressions
100100
101- A [ path] ( #paths ) used as an expression context denotes either a local variable
102- or an item. Path expressions are [ lvalues] ( #lvalues-rvalues-and-temporaries ) .
101+ A [ path] ( paths.html ) used as an expression context denotes either a local
102+ variable or an item. Path expressions are
103+ [ lvalues] ( expressions.html#lvalues-rvalues-and-temporaries ) .
103104
104105## Tuple expressions
105106
106107Tuples are written by enclosing zero or more comma-separated expressions in
107- parentheses. They are used to create [ tuple-typed] ( #tuple-types ) values.
108+ parentheses. They are used to create [ tuple-typed] ( types.html#tuple-types )
109+ values.
108110
109111``` {.tuple}
110112(0.0, 4.5);
@@ -122,21 +124,20 @@ comma:
122124## Struct expressions
123125
124126There are several forms of struct expressions. A _ struct expression_
125- consists of the [ path] ( #paths ) of a [ struct item] ( #structs ) , followed by
126- a brace-enclosed list of zero or more comma-separated name-value pairs,
127- providing the field values of a new instance of the struct. A field name
128- can be any identifier, and is separated from its value expression by a colon.
129- The location denoted by a struct field is mutable if and only if the
130- enclosing struct is mutable.
127+ consists of the [ path] ( #paths ) of a [ struct item] ( items.html #structs) , followed
128+ by a brace-enclosed list of zero or more comma-separated name-value pairs,
129+ providing the field values of a new instance of the struct. A field name can be
130+ any identifier, and is separated from its value expression by a colon. The
131+ location denoted by a struct field is mutable if and only if the enclosing
132+ struct is mutable.
131133
132134A _ tuple struct expression_ consists of the [ path] ( #paths ) of a [ struct
133- item] ( #structs ) , followed by a parenthesized list of one or more
134- comma-separated expressions (in other words, the path of a struct item
135- followed by a tuple expression). The struct item must be a tuple struct
136- item.
135+ item] ( items.html#structs ) , followed by a parenthesized list of one or more
136+ comma-separated expressions (in other words, the path of a struct item followed
137+ by a tuple expression). The struct item must be a tuple struct item.
137138
138139A _ unit-like struct expression_ consists only of the [ path] ( #paths ) of a
139- [ struct item] ( #structs ) .
140+ [ struct item] ( items.html #structs) .
140141
141142The following are examples of struct expressions:
142143
@@ -216,24 +217,24 @@ A _method call_ consists of an expression followed by a single dot, an
216217identifier, and a parenthesized expression-list. Method calls are resolved to
217218methods on specific traits, either statically dispatching to a method if the
218219exact ` self ` -type of the left-hand-side is known, or dynamically dispatching if
219- the left-hand-side expression is an indirect [ trait object] ( # trait-objects) .
220+ the left-hand-side expression is an indirect [ trait object] ( trait-objects.html ) .
220221
221222## Field expressions
222223
223224A _ field expression_ consists of an expression followed by a single dot and an
224225identifier, when not immediately followed by a parenthesized expression-list
225226(the latter is a [ method call expression] ( #method-call-expressions ) ). A field
226- expression denotes a field of a [ struct] ( #struct-types ) .
227+ expression denotes a field of a [ struct] ( types.html #struct-types) .
227228
228229``` {.ignore .field}
229230mystruct.myfield;
230231foo().x;
231232(Struct {a: 10, b: 20}).a;
232233```
233234
234- A field access is an [ lvalue] ( #lvalues-rvalues-and-temporaries ) referring to
235- the value of that field. When the type providing the field inherits mutability,
236- it can be [ assigned] ( #assignment-expressions ) to.
235+ A field access is an [ lvalue] ( expressions.html #lvalues-rvalues-and-temporaries)
236+ referring to the value of that field. When the type providing the field
237+ inherits mutability, it can be [ assigned] ( #assignment-expressions ) to.
237238
238239Also, if the type of the expression to the left of the dot is a
239240pointer, it is automatically dereferenced as many times as necessary
@@ -242,12 +243,13 @@ fewer autoderefs to more.
242243
243244## Array expressions
244245
245- An [ array] ( #array-and-slice-types ) _ expression_ is written by enclosing zero
246- or more comma-separated expressions of uniform type in square brackets.
246+ An [ array] ( types.html#array-and-slice-types ) _ expression_ is written by
247+ enclosing zero or more comma-separated expressions of uniform type in square
248+ brackets.
247249
248250In the ` [expr ';' expr] ` form, the expression after the ` ';' ` must be a
249251constant expression that can be evaluated at compile time, such as a
250- [ literal] ( #literals ) or a [ static item] ( #static-items ) .
252+ [ literal] ( tokens.html #literals) or a [ static item] ( items.html #static-items) .
251253
252254```
253255[1, 2, 3, 4];
@@ -258,14 +260,15 @@ constant expression that can be evaluated at compile time, such as a
258260
259261## Index expressions
260262
261- [ Array] ( #array-and-slice-types ) -typed expressions can be indexed by
263+ [ Array] ( types.html #array-and-slice-types) -typed expressions can be indexed by
262264writing a square-bracket-enclosed expression (the index) after them. When the
263- array is mutable, the resulting [ lvalue ] ( #lvalues-rvalues-and-temporaries ) can
264- be assigned to.
265+ array is mutable, the resulting
266+ [ lvalue ] ( expressions.html#lvalues-rvalues-and-temporaries ) can be assigned to.
265267
266268Indices are zero-based, and may be of any integral type. Vector access is
267- bounds-checked at compile-time for constant arrays being accessed with a constant index value.
268- Otherwise a check will be performed at run-time that will put the thread in a _ panicked state_ if it fails.
269+ bounds-checked at compile-time for constant arrays being accessed with a
270+ constant index value. Otherwise a check will be performed at run-time that
271+ will put the thread in a _ panicked state_ if it fails.
269272
270273``` {should-fail}
271274([1, 2, 3, 4])[0];
@@ -333,14 +336,15 @@ all written as prefix operators, before the expression they apply to.
333336 is an error to apply negation to unsigned types; for example, the compiler
334337 rejects ` -1u32 ` .
335338* ` * `
336- : Dereference. When applied to a [ pointer] ( #pointer-types ) it denotes the
337- pointed-to location. For pointers to mutable locations, the resulting
338- [ lvalue] ( #lvalues-rvalues-and-temporaries ) can be assigned to.
339- On non-pointer types, it calls the ` deref ` method of the ` std::ops::Deref `
340- trait, or the ` deref_mut ` method of the ` std::ops::DerefMut ` trait (if
341- implemented by the type and required for an outer expression that will or
342- could mutate the dereference), and produces the result of dereferencing the
343- ` & ` or ` &mut ` borrowed pointer returned from the overload method.
339+ : Dereference. When applied to a [ pointer] ( types.html#pointer-types ) it
340+ denotes the pointed-to location. For pointers to mutable locations, the
341+ resulting [ lvalue] ( expressions.html#lvalues-rvalues-and-temporaries ) can be
342+ assigned to. On non-pointer types, it calls the ` deref ` method of the
343+ ` std::ops::Deref ` trait, or the ` deref_mut ` method of the
344+ ` std::ops::DerefMut ` trait (if implemented by the type and required for an
345+ outer expression that will or could mutate the dereference), and produces
346+ the result of dereferencing the ` & ` or ` &mut ` borrowed pointer returned
347+ from the overload method.
344348* ` ! `
345349 : Logical negation. On the boolean type, this flips between ` true ` and
346350 ` false ` . On integer types, this inverts the individual bits in the
@@ -480,8 +484,9 @@ surprising side-effects on the dynamic execution semantics.
480484### Assignment expressions
481485
482486An _ assignment expression_ consists of an
483- [ lvalue] ( #lvalues-rvalues-and-temporaries ) expression followed by an equals
484- sign (` = ` ) and an [ rvalue] ( #lvalues-rvalues-and-temporaries ) expression.
487+ [ lvalue] ( expressions.html#lvalues-rvalues-and-temporaries ) expression followed
488+ by an equals sign (` = ` ) and an
489+ [ rvalue] ( expressions.html#lvalues-rvalues-and-temporaries ) expression.
485490
486491Evaluating an assignment expression [ either copies or
487492moves] ( #moved-and-copied-types ) its right-hand operand to its left-hand
@@ -571,15 +576,16 @@ Lambda expressions are most useful when passing functions as arguments to other
571576functions, as an abbreviation for defining and capturing a separate function.
572577
573578Significantly, lambda expressions _ capture their environment_ , which regular
574- [ function definitions] ( #functions ) do not. The exact type of capture depends
575- on the [ function type] ( #function-types ) inferred for the lambda expression. In
576- the simplest and least-expensive form (analogous to a ``` || { } ``` expression),
577- the lambda expression captures its environment by reference, effectively
578- borrowing pointers to all outer variables mentioned inside the function.
579- Alternately, the compiler may infer that a lambda expression should copy or
580- move values (depending on their type) from the environment into the lambda
581- expression's captured environment. A lambda can be forced to capture its
582- environment by moving values by prefixing it with the ` move ` keyword.
579+ [ function definitions] ( items.html#functions ) do not. The exact type of capture
580+ depends on the [ function type] ( types.html#function-types ) inferred for the
581+ lambda expression. In the simplest and least-expensive form (analogous to a
582+ ``` || { } ``` expression), the lambda expression captures its environment by
583+ reference, effectively borrowing pointers to all outer variables mentioned
584+ inside the function. Alternately, the compiler may infer that a lambda
585+ expression should copy or move values (depending on their type) from the
586+ environment into the lambda expression's captured environment. A lambda can be
587+ forced to capture its environment by moving values by prefixing it with the
588+ ` move ` keyword.
583589
584590In this example, we define a function ` ten_times ` that takes a higher-order
585591function argument, and we then call it with a lambda expression as an argument,
@@ -715,12 +721,13 @@ stands for a *single* data field, whereas a wildcard `..` stands for *all* the
715721fields of a particular variant.
716722
717723A ` match ` behaves differently depending on whether or not the head expression
718- is an [ lvalue or an rvalue] ( #lvalues-rvalues-and-temporaries ) . If the head
719- expression is an rvalue, it is first evaluated into a temporary location, and
720- the resulting value is sequentially compared to the patterns in the arms until
721- a match is found. The first arm with a matching pattern is chosen as the branch
722- target of the ` match ` , any variables bound by the pattern are assigned to local
723- variables in the arm's block, and control enters the block.
724+ is an [ lvalue or an rvalue] ( expressions.html#lvalues-rvalues-and-temporaries ) .
725+ If the head expression is an rvalue, it is first evaluated into a temporary
726+ location, and the resulting value is sequentially compared to the patterns in
727+ the arms until a match is found. The first arm with a matching pattern is
728+ chosen as the branch target of the ` match ` , any variables bound by the pattern
729+ are assigned to local variables in the arm's block, and control enters the
730+ block.
724731
725732When the head expression is an lvalue, the match does not allocate a temporary
726733location (however, a by-value binding may copy or move from the lvalue). When
0 commit comments