DST - Dynamically Sized Types

Introduction

Dynamically Sized Types (DSTs) are types, primarily found in languages like Rust, whose exact size in memory is not known at compile time. This contrasts with most types which have a fixed, compile-time known size.

Compile-Time Size vs. Runtime Size

Common Examples of DSTs (in Rust)

The Core Limitation and Solution

"Fat Pointers"

Pointers to DSTs are often called "fat pointers" because they carry extra metadata alongside the memory address:

Sized and ?Sized

Summary

In short, DSTs are types like slices ([T]) and trait objects (dyn Trait) whose size isn't fixed at compile time. They must always be used behind a pointer (like &, Box, Rc), which becomes a "fat pointer" carrying the necessary runtime metadata (length or vtable pointer) to manage the dynamically sized data. The ?Sized trait bound is used to indicate that a generic type parameter might be a DST.