@@ -87,7 +87,7 @@ let a = & & & & mut 10;
87
87
The ` * ` (dereference) operator is also a unary prefix operator. When applied to
88
88
a [ pointer] ( types.html#pointer-types ) it denotes the pointed-to location. If
89
89
the expression is of type ` &mut T ` and ` *mut T ` , and is either a local
90
- variable, a (nested) field of a local variance or is a mutable [ place
90
+ variable, a (nested) field of a local variable or is a mutable [ place
91
91
expression] , then the resulting memory location can be assigned to.
92
92
Dereferencing a raw pointer requires ` unsafe ` .
93
93
@@ -207,15 +207,17 @@ expression context][value expression] so are moved or copied.
207
207
| ` + ` | Addition | | Addition | ` std::ops::Add ` |
208
208
| ` - ` | Subtraction | | Subtraction | ` std::ops::Sub ` |
209
209
| ` * ` | Multiplication | | Multiplication | ` std::ops::Mul ` |
210
- | ` / ` | Division | | Division | ` std::ops::Div ` |
210
+ | ` / ` | Division* | | Division | ` std::ops::Div ` |
211
211
| ` % ` | Remainder | | Remainder | ` std::ops::Rem ` |
212
212
| ` & ` | Bitwise AND | Logical AND | | ` std::ops::BitAnd ` |
213
213
| <code >| ; </code > | Bitwise OR | Logical OR | | ` std::ops::BitOr ` |
214
214
| ` ^ ` | Bitwise XOR | Logical XOR | | ` std::ops::BitXor ` |
215
215
| ` << ` | Left Shift | | | ` std::ops::Shl ` |
216
- | ` >> ` | Right Shift* | | | ` std::ops::Shr ` |
216
+ | ` >> ` | Right Shift** | | | ` std::ops::Shr ` |
217
217
218
- \* Arithmetic right shift on signed integer types, logical right shift on
218
+ \* Integer division rounds towards zero.
219
+
220
+ \*\* Arithmetic right shift on signed integer types, logical right shift on
219
221
unsigned integer types.
220
222
221
223
Here are examples of these operators being used.
@@ -345,10 +347,13 @@ well as the following additional casts. Here `*T` means either `*const T` or
345
347
| ` &[T; n] ` | ` *const T ` | Array to pointer cast |
346
348
| [ Function pointer] ( types.html#function-pointer-types ) | ` *V ` where ` V: Sized ` | Function pointer to pointer cast |
347
349
| Function pointer | Integer | Function pointer to address cast |
350
+ | Closure \*\* | Function pointer | Closure to function pointer cast |
348
351
349
352
\* or ` T ` and ` V ` are compatible unsized types, e.g., both slices, both the
350
353
same trait object.
351
354
355
+ \*\* only for closures that do capture (close over) any local variables
356
+
352
357
### Semantics
353
358
354
359
* Numeric cast
@@ -390,7 +395,8 @@ same trait object.
390
395
>   ;  ; | [ _ Expression_ ] ` = ` [ _ Expression_ ]
391
396
392
397
An _ assignment expression_ consists of a [ place expression] followed by an
393
- equals sign (` = ` ) and a [ value expression] .
398
+ equals sign (` = ` ) and a [ value expression] . Such an expression always has
399
+ the [ ` unit ` type] .
394
400
395
401
Evaluating an assignment expression [ drops] ( destructors.html ) the left-hand
396
402
operand, unless it's an uninitialized local variable or field of a local variable,
0 commit comments