patterns icon indicating copy to clipboard operation
patterns copied to clipboard

Add "Destructure as a Reminder" idiom?

Open Expurple opened this issue 4 months ago • 0 comments

TL;DR:

// Destructure without `..` to cause a compile error when a new field is added.
// It will remind us to use the new field here.
let MyStruct { field1, field2 } = my_struct;

in a method that needs to handle every single field, including future ones.

Blog post with examples.

Expurple avatar Aug 30 '25 08:08 Expurple