Modeling Open and Closed Universes of Choices in Rust

This article explores how to model choices in Rust, distinguishing between closed universes (where all options are known and fixed, like Rust's `Option` type) and open universes (where new options can be added). For closed universes, enums are suitable. Semi-open universes (where library authors can add options but users can't), are best handled with non-exhaustive enums, forcing users to account for wildcard patterns and ensuring API backward compatibility. Fully open universes are best addressed with strings or newtypes, or traits for more flexibility. The article also discusses the pitfalls of using an 'Unknown' variant and explores the use of sealed traits. The author concludes by recommending a case-by-case approach, weighing the trade-offs between the simpler string-based approach and the more powerful, yet more complex, trait-based approach.