10.2 Smart Pointers
Smart pointers in Rust are a powerful concept, going beyond simple references by allowing for more advanced memory management capabilities.
Before getting started, an essential distinction to make is the key difference between a pointer and a smart pointer. A simple pointer variable stores the memory address of some value. We’ve been using such pointers throughout this book, indicated by an ampersand (&); they are also referred to as a “reference.” Other than referring to or pointing to some value, these references don’t have any other additional capabilities. In contrast to simple pointers, smart pointers are not just simple references. They have special capabilities and also metadata. We’ll start with the simplest smart ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access