Image missing.
Parse, Don't Validate and Type-Driven Design in Rust

created: Feb. 21, 2026, 7:40 p.m. | updated: Feb. 22, 2026, 7:23 a.m.

This is especially important when some operations don’t fail loudly, like the following: fn divide_floats ( a : f32 , b : f32 ) -> f32 { a / b } fn main () { let a = 5 . fn divide_floats ( a : f32 , b : f32 ) -> f32 { assert_ne! We’ll name it NonZeroF32 : struct NonZeroF32 ( f32 ); This struct only contains a single field f32 . fn divide_floats ( a : f32 , b : NonZeroF32 ) -> f32 { a / b } There is an interesting implication in this pattern. fn roots ( a : f32 , b : f32 , c : f32 ) -> [ f32 ; 2 ] { // For the sake of demonstration we will be ignoring complex roots let discriminant = b * b - 4 * a * c ; [ - b + discriminant .

12 hours, 54 minutes ago: Hacker News