Skip to content

Commit 0ff7bac

Browse files
committed
auto merge of #16924 : steveklabnik/rust/manual_pointer_fix, r=pcwalton
This was brought up in IRC: https://botbot.me/mozilla/rust/2014-08-30/?msg=20733803&page=26
2 parents 0bdac78 + d32bfe8 commit 0ff7bac

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/doc/rust.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are four varieties of pointer in Rust:
3672-
3673-
* Owning pointers (`Box`)
3674-
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675-
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676-
Owning pointers are written `Box<content>`,
3677-
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678-
Copying an owned box is a "deep" operation:
3679-
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680-
Releasing an owning pointer immediately releases its corresponding owned box.
3671+
There are two varieties of pointer in Rust:
36813672

36823673
* References (`&`)
36833674
: These point to memory _owned by some other value_.
3684-
References arise by (automatic) conversion from owning pointers, managed pointers,
3685-
or by applying the borrowing operator `&` to some other value,
3686-
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687-
A borrow expression is written `&content`.
3688-
3689-
A reference type is written `&'f type` for some lifetime-variable `f`,
3690-
or just `&type` when the lifetime can be elided;
3691-
for example `&int` means a reference to an integer.
3675+
A reference type is written `&type` for some lifetime-variable `f`,
3676+
or just `&'a type` when you need an explicit lifetime.
36923677
Copying a reference is a "shallow" operation:
36933678
it involves only copying the pointer itself.
36943679
Releasing a reference typically has no effect on the value it points to,
3695-
with the exception of temporary values,
3696-
which are released when the last reference to them is released.
3680+
with the exception of temporary values, which are released when the last
3681+
reference to them is released.
36973682

36983683
* Raw pointers (`*`)
36993684
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust:
37063691
they exist to support interoperability with foreign code,
37073692
and writing performance-critical or low-level functions.
37083693

3694+
The standard library contains addtional 'smart pointer' types beyond references
3695+
and raw pointers.
3696+
37093697
### Function types
37103698

37113699
The function type constructor `fn` forms new function types.

0 commit comments

Comments
 (0)