Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

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 a Shipment<Packed> fails with E0599, because deliver exists only on Shipment<InTransit>.

Read the full section →