Why Exhaustive Destructuring in Rust Makes Your Code Safer
In Praise of Exhaustive Destructuring
I initially found Rust's requirement to list all struct fields during destructuring frustrating compared to TypeScript or Haskell. However, I now realize this strictness prevents dangerous bugs when adding new fields. By forcing the compiler to catch missing cases, exhaustive destructuring ensures my code remains robust and up-to-date as data structures evolve.
"That function is dangerous! To see why, let's suppose some stations now have an anemometer and are able to record wind speed."