Idea: Making API commitments explicit

One way I've seen something like this come up previously was as something like #[non_exhaustive(but_all_the_fields_are_public)] or #[non_exhaustive(but_new_things_will_have_defaults)] or similar -- placeholder names, obviously -- to change it from "well you can change that type in any way" to "the changes are restricted in some ways to enable other functionality.

For example, but_all_the_fields_are_public would enable using FRU and but_new_things_will_have_defaults would allow constructing it with Foo { .. }.

5 Likes