Understanding Rust Smart Pointers

João Henrique Machado Silva
The Polyglot Programmer
10 min readMay 22, 2021

--

What are they and how do they work?

On this post I intend to walk down memory lane a bit to understand what exactly are Smart Pointers? Where do they come from? And of course, how do they work?

Very simply, a smart pointer is an abstract data type that simulates a pointer while providing added features, such as automatic memory management and bounds checking. These are intended to reduce bugs caused by the misuse of pointers, while retaining efficiency.

Before we talk about how Rust deals with Smart Pointers, let’s go back a little and take a look at the history and where smart pointers came from.

A little bit of history

Smart pointers were first popularized in the programming language C++ during the first half of the 1990s as rebuttal to criticisms of C++’s lack of automatic garbage collection.

Even though the concept of smart pointers was popularized with C++, especially the reference-counted type of smart pointers, the immediate predecessor of one of the languages that inspired C++’s design had reference-counted references built into the language. C++ was inspired in part by Simula67 and Simula67’s ancestor was Simula I. Insofar as Simula I’s element is analogous to C++’s pointer without null, and insofar as Simula I’s process with a…

--

--