@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668
36693669All pointers in Rust are explicit first-class values.
36703670They 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
37113699The function type constructor ` fn ` forms new function types.
0 commit comments