Skip to content

Commit f1002ea

Browse files
authored
Merge pull request #337 from bstrie/patch-4
Fixups for operator ref
2 parents d39a3e1 + b614ebd commit f1002ea

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/expressions/operator-expr.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let a = & & & & mut 10;
8787
The `*` (dereference) operator is also a unary prefix operator. When applied to
8888
a [pointer](types.html#pointer-types) it denotes the pointed-to location. If
8989
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
9191
expression], then the resulting memory location can be assigned to.
9292
Dereferencing a raw pointer requires `unsafe`.
9393

@@ -207,15 +207,17 @@ expression context][value expression] so are moved or copied.
207207
| `+` | Addition | | Addition | `std::ops::Add` |
208208
| `-` | Subtraction | | Subtraction | `std::ops::Sub` |
209209
| `*` | Multiplication | | Multiplication | `std::ops::Mul` |
210-
| `/` | Division | | Division | `std::ops::Div` |
210+
| `/` | Division* | | Division | `std::ops::Div` |
211211
| `%` | Remainder | | Remainder | `std::ops::Rem` |
212212
| `&` | Bitwise AND | Logical AND | | `std::ops::BitAnd` |
213213
| <code>&#124;</code> | Bitwise OR | Logical OR | | `std::ops::BitOr` |
214214
| `^` | Bitwise XOR | Logical XOR | | `std::ops::BitXor` |
215215
| `<<` | Left Shift | | | `std::ops::Shl` |
216-
| `>>` | Right Shift* | | | `std::ops::Shr` |
216+
| `>>` | Right Shift** | | | `std::ops::Shr` |
217217

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
219221
unsigned integer types.
220222

221223
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
345347
| `&[T; n]` | `*const T` | Array to pointer cast |
346348
| [Function pointer](types.html#function-pointer-types) | `*V` where `V: Sized` | Function pointer to pointer cast |
347349
| Function pointer | Integer | Function pointer to address cast |
350+
| Closure \*\* | Function pointer | Closure to function pointer cast |
348351

349352
\* or `T` and `V` are compatible unsized types, e.g., both slices, both the
350353
same trait object.
351354

355+
\*\* only for closures that do capture (close over) any local variables
356+
352357
### Semantics
353358

354359
* Numeric cast
@@ -390,7 +395,8 @@ same trait object.
390395
> &nbsp;&nbsp; | [_Expression_] `=` [_Expression_]
391396
392397
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].
394400

395401
Evaluating an assignment expression [drops](destructors.html) the left-hand
396402
operand, unless it's an uninitialized local variable or field of a local variable,

0 commit comments

Comments
 (0)