ffminus
Re:API design note: Beware of adding an "Other" enum value
on Monday March 03, 2025 @12:22AM (#43238540)
It lets you have a middle ground, with the decision of when breaking happens left up to library users.
Without non_exhaustive, all consumers always get your second scenario. With non_exhaustive, individual zoos get to pick their own policy of when/if animals should starve.
Each option has its place, it depends on context. Does the creator of the type want/need strictness from all their consumers, or can this call be left up to each consumer to make? The lint puts strictness back on the table as an opt-in for individual users.
Re:API design note: Beware of adding an "Other" enum value
on Sunday March 02, 2025 @07:40PM (#43237013)
Library users can force a compile error when new variants get added, using a lint from rustc. It's "allow" by default, so it's opt-in.
https://doc.rust-lang.org/rustc/lints/listing/allowed-by-def...