A Rust-centric explanation of the 'Parse, don't Validate' pattern and type-driven design. Using examples like NonZeroF32 and NonEmptyVec newtypes, the post demonstrates how encoding invariants into types at compile time is superior to runtime validation. Key ideas include making illegal states unrepresentable, pushing

13m read time From harudagondi.space
Post cover image
Table of contents
Table of ContentsDividing by zero #Examples in the wild #Maxims of Type Driven Design #What can we do? #Conclusion #

Sort: