Dynamically Sized Type

In Rust, most types have a size known at compile time - an  is 8 bytes, a character 4, and so on. These types all implement the auto trait. However, not all types do - some types have a size that is only known at runtime. These types are called dynamically sized types, or DSTs.

There are four kinds of DSTs in Rust:
 * Dynamic trait objects . As they can be any type, they have an unknown size.
 * The slice type . It contains any number of.
 * The string slice type . The string slice can contain any number of characters.
 * Structs and enums that contain other DSTs.

As DSTs are unsized, they can't be held on the stack like a regular variable - you must store a pointer to them; this can be a reference or it can be through a container like a  or an.

Pointers and references to DSTs in Rust are "fat" - instead of simply storing the address of the value they store the address and size of the value, so they are twice as wide as a regular pointer.

At the moment, DSTs are very hard to work with mostly because they can't be stored on the stack which eliminates the usage of most of Rust's functions. This will hopefully get better in the future - at the moment, try to avoid them.

Sized Bounds
Because DSTs are so difficult to work with, all generics implicitly require. To either require unsized types or to support both you can write  or   respectively; for example   has   which allows it to store both sized and unsized values.