Type Driven Design

Make illegal states unrepresentable — enums instead of boolean and string flags, newtypes instead of bare primitives, parsed types instead of validated ones, typestate for protocol order. Use when a struct has fields that are only valid in some combinations, when validation is re-checked at many call sites, when boolean flags multiply, or when the user asks how to model a domain in Rust.

rewrite-rs 8ed8f92 4 files · 13.1 KB Updated

File contents

rewrite-rs/skills/tree/main/skills/rust/type-driven-design commit 8ed8f92028

Frequently asked questions

npx skillmds@latest add rewrite-rs/type-driven-design