Rust, Software Development

Using #[non_exhaustive] for Non-exhaustive Structs

Non-exhaustive structs will future-proof our codes. We use Struct expressions to instantiate structs and they’re JSON-like expression in appearance with all fields present. When we update a struct with a new field,  all expressions must be updated to include that field.

Read More...

Rust, Software Development

Using #[non_exhaustive] for Non-exhaustive Enums

Using non-exhaustive enums in one crate prevents codes in other crates from listing all the possible matches in a match expression. It forces developers to use wildcards for future-proofing.

Read More...