data structures that act like a pointer but also have additional metadata and capabilities.
while references only borrow data, in many cases, smart pointers own the data they point to.
smart pointers implement the Deref
and Drop
traits.
- Most common
Box<T>
for allocating values on the heapRc<T>
, a reference counting type that enables multiple ownershipRef<T>
andRefMut<T>
, accessed throughRefCell<T>
, a type that enforces the borrowing rules at runtime instead of compile time