mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
tutorial: Emphasize GC in shared box section
This commit is contained in:
parent
95f6e525d7
commit
0385ae17d3
@ -1266,13 +1266,7 @@ All pointer types can be dereferenced with the `*` unary operator.
|
||||
|
||||
## Shared boxes
|
||||
|
||||
Shared boxes are pointers to heap-allocated, reference counted memory.
|
||||
A cycle collector ensures that circular references do not result in
|
||||
memory leaks.
|
||||
|
||||
> ***Note:*** We will in the future switch to garbage collection,
|
||||
> rather than reference counting, for shared boxes.
|
||||
|
||||
Shared boxes are pointers to heap-allocated, garbage collected memory.
|
||||
Creating a shared box is done by simply applying the unary `@`
|
||||
operator to an expression. The result of the expression will be boxed,
|
||||
resulting in a box of the right type. Copying a shared box, as happens
|
||||
@ -1287,6 +1281,10 @@ let y = x; // Copy the pointer, increase refcount
|
||||
|
||||
Shared boxes never cross task boundaries.
|
||||
|
||||
> ***Note:*** shared boxes are currently reclaimed through reference
|
||||
> counting and cycle collection, but we will switch to a tracing
|
||||
> garbage collector.
|
||||
|
||||
## Unique boxes
|
||||
|
||||
In contrast to shared boxes, unique boxes have a single owner and thus
|
||||
|
Loading…
Reference in New Issue
Block a user