Overview of pointers
In the following table we summarize the different pointers used in Rust. T
represents a generic type. We haven't yet encountered the Arc
, *const
and *mut
pointers, but they are included here for completeness.
Notation | Pointer type | What can this pointer do? |
| Reference | Allows one or more references to read |
| Mutable Reference | Allows a single reference to read and write |
| Box | Heap allocated |
|
| Heap allocated |
| Shared mutable memory location with | |
| Mutable memory location | |
|
| Same as above, but safe mutable sharing across threads (see Chapter 8, Concurrency - Coding for Multicore Execution) |
| Raw pointer | Unsafe read access to |
| Mutable raw pointer | Unsafe read and write access to |