The Developer’s Cry

Yet another blog by a hobbyist programmer

A Visual Map Of Rust Types

I made a visual map of commonly used Rust data types. While the Rust documentation is quite alright, it helps to have a visual overview of how these types are laid out in memory. Knowing the layout is important for getting a deep understanding of what exactly happens when you move, copy, or clone an instance.

This data layout applies to many programming languages, but I feel it’s particularly interesting for Rust because the language relies heavily on move semantics and references.

Visualizing it helps a lot, for example in reasoning about what a reference to an Rc is, or in realizing that passing a large Vec to a function is a cheap operation, or in explaining that the backend storage of a Vec not only may grow, but also may be completely reallocated (and thus be relocated in memory) without you needing to explicitly be aware of that.