Dynamically sized types

Most types have a fixed size that is known at compile time and implement the trait Sized. A type with a size that is known only at run-time is called a dynamically sized type (DST) or, informally, an unsized type. Slices, trait objects, and str are examples of DSTs.

Such types can only be used in certain cases:

Note

Variables, function parameters, const items, and static items must be Sized.

The unsized tail of a type is the dynamically sized component that the metadata of a pointer to the type describes. A slice ([T]) and a str are each their own unsized tail, described by a length; a trait object (dyn Trait) is its own unsized tail, described by a pointer to a vtable. When a struct (per dynamic-sized.struct-field) or a tuple has an unsized last field, its unsized tail is the unsized tail of that field. A sized type has no unsized tail.