Skip to content

Commit

Permalink
Merge pull request rust-lang#337 from bstrie/patch-4
Browse files Browse the repository at this point in the history
Fixups for operator ref
  • Loading branch information
Havvy authored Jun 1, 2018
2 parents d39a3e1 + b614ebd commit f1002ea
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let a = & & & & mut 10;
The `*` (dereference) operator is also a unary prefix operator. When applied to
a [pointer](types.html#pointer-types) it denotes the pointed-to location. If
the expression is of type `&mut T` and `*mut T`, and is either a local
variable, a (nested) field of a local variance or is a mutable [place
variable, a (nested) field of a local variable or is a mutable [place
expression], then the resulting memory location can be assigned to.
Dereferencing a raw pointer requires `unsafe`.

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

\* Arithmetic right shift on signed integer types, logical right shift on
\* Integer division rounds towards zero.

\*\* Arithmetic right shift on signed integer types, logical right shift on
unsigned integer types.

Here are examples of these operators being used.
Expand Down Expand Up @@ -345,10 +347,13 @@ well as the following additional casts. Here `*T` means either `*const T` or
| `&[T; n]` | `*const T` | Array to pointer cast |
| [Function pointer](types.html#function-pointer-types) | `*V` where `V: Sized` | Function pointer to pointer cast |
| Function pointer | Integer | Function pointer to address cast |
| Closure \*\* | Function pointer | Closure to function pointer cast |

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

\*\* only for closures that do capture (close over) any local variables

### Semantics

* Numeric cast
Expand Down Expand Up @@ -390,7 +395,8 @@ same trait object.
> &nbsp;&nbsp; | [_Expression_] `=` [_Expression_]
An _assignment expression_ consists of a [place expression] followed by an
equals sign (`=`) and a [value expression].
equals sign (`=`) and a [value expression]. Such an expression always has
the [`unit` type].

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

0 comments on commit f1002ea

Please sign in to comment.