@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
3668
3668
3669
3669
All pointers in Rust are explicit first-class values.
3670
3670
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:
3681
3672
3682
3673
* References (` & ` )
3683
3674
: 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.
3692
3677
Copying a reference is a "shallow" operation:
3693
3678
it involves only copying the pointer itself.
3694
3679
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.
3697
3682
3698
3683
* Raw pointers (` * ` )
3699
3684
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust:
3706
3691
they exist to support interoperability with foreign code,
3707
3692
and writing performance-critical or low-level functions.
3708
3693
3694
+ The standard library contains addtional 'smart pointer' types beyond references
3695
+ and raw pointers.
3696
+
3709
3697
### Function types
3710
3698
3711
3699
The function type constructor ` fn ` forms new function types.
0 commit comments