Skip to content

Commit c46706f

Browse files
committed
manual: add borrow operator to symbolic unary operator list; mention copy and move.
1 parent e257f39 commit c46706f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

doc/rust.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,9 @@ task in a _failing state_.
16361636

16371637
### Unary operator expressions
16381638

1639-
Rust defines five unary operators. They are all written as prefix
1640-
operators, before the expression they apply to.
1639+
Rust defines six symbolic unary operators,
1640+
in addition to the unary [copy](#unary-copy-expressions) and [move](#unary-move-expressions) operators.
1641+
They are all written as prefix operators, before the expression they apply to.
16411642

16421643
`-`
16431644
: Negation. May only be applied to numeric types.
@@ -1652,9 +1653,12 @@ operators, before the expression they apply to.
16521653
`false`. On integer types, this inverts the individual bits in the
16531654
two's complement representation of the value.
16541655
`@` and `~`
1655-
: [Boxing](#box-types) operators. Allocate a box to hold the value
1656-
they are applied to, and store the value in it. `@` creates a
1657-
shared, reference-counted box, whereas `~` creates a unique box.
1656+
: [Boxing](#pointer-types) operators. Allocate a box to hold the value they are applied to,
1657+
and store the value in it. `@` creates a managed box, whereas `~` creates an owned box.
1658+
`&`
1659+
: Borrow operator. Returns a borrowed pointer, pointing to its operand.
1660+
The operand of a borrowed pointer is statically proven to outlive the resulting pointer.
1661+
If the borrow-checker cannot prove this, it is a compilation error.
16581662

16591663
### Binary operator expressions
16601664

0 commit comments

Comments
 (0)