November 2017
Intermediate to advanced
264 pages
5h 45m
English
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? |
|
&T |
Reference |
Allows one or more references to read T |
|
&mut T |
Mutable Reference |
Allows a single reference to read and write T |
|
Box<T> |
Box |
Heap allocated T with a single owner that may read and write T. |
|
Rc<T> |
Rc pointer |
Heap allocated T with many readers |
|
Cell<T> |
Shared mutable memory location with Copy implemented |
|
|
RefCell<T> |
Mutable memory location |
|
|
Arc<T> |
Arc pointer |
Same as above, but safe mutable sharing across ... |
Read now
Unlock full access