manual: add borrow operator to symbolic unary operator list; mention copy and move.
This commit is contained in:
parent
e257f390e1
commit
c46706fffd
1 changed files with 9 additions and 5 deletions
14
doc/rust.md
14
doc/rust.md
|
@ -1636,8 +1636,9 @@ task in a _failing state_.
|
||||||
|
|
||||||
### Unary operator expressions
|
### Unary operator expressions
|
||||||
|
|
||||||
Rust defines five unary operators. They are all written as prefix
|
Rust defines six symbolic unary operators,
|
||||||
operators, before the expression they apply to.
|
in addition to the unary [copy](#unary-copy-expressions) and [move](#unary-move-expressions) operators.
|
||||||
|
They are all written as prefix operators, before the expression they apply to.
|
||||||
|
|
||||||
`-`
|
`-`
|
||||||
: Negation. May only be applied to numeric types.
|
: Negation. May only be applied to numeric types.
|
||||||
|
@ -1652,9 +1653,12 @@ operators, before the expression they apply to.
|
||||||
`false`. On integer types, this inverts the individual bits in the
|
`false`. On integer types, this inverts the individual bits in the
|
||||||
two's complement representation of the value.
|
two's complement representation of the value.
|
||||||
`@` and `~`
|
`@` and `~`
|
||||||
: [Boxing](#box-types) operators. Allocate a box to hold the value
|
: [Boxing](#pointer-types) operators. Allocate a box to hold the value they are applied to,
|
||||||
they are applied to, and store the value in it. `@` creates a
|
and store the value in it. `@` creates a managed box, whereas `~` creates an owned box.
|
||||||
shared, reference-counted box, whereas `~` creates a unique box.
|
`&`
|
||||||
|
: Borrow operator. Returns a borrowed pointer, pointing to its operand.
|
||||||
|
The operand of a borrowed pointer is statically proven to outlive the resulting pointer.
|
||||||
|
If the borrow-checker cannot prove this, it is a compilation error.
|
||||||
|
|
||||||
### Binary operator expressions
|
### Binary operator expressions
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue