typestate
Using types to make illegal state changes fail to compile.
The typestate pattern encodes an object's state as a type parameter or separate type; transitions consume self and return the next state's type, so invalid calls don't exist.
Examples
Calling
.deliver()on aShipment<Packed>fails with E0599, becausedeliverexists only onShipment<InTransit>.
See also