Uses of Box:
- For recursive types: Since their size cannot be known at compile time, rust uses a
Boxwhich is a pointer on the stack to contents on the heap.
enum List {
Cons(i16, Box<List>),
Nil,
}
Data larger than the stack (staci is typically up to ~8MB).
Trait objects