#[non_exhaustive]'s ability to prevent downstream users from *creating* structs, enums, and enum variants looks like it could be used for new API patterns. Tricky part re: invariant enforcement is users can still replace fields if they have owned/mutable access.https://twitter.com/rustlang/status/1207693777143549953 …
-
Show this thread
-
Replying to @peterktodd
You could do this previously but it required a lot of boilerplate. See the modules example here:https://words.steveklabnik.com/structure-literals-vs-constructors-in-rust …
1 reply 0 retweets 2 likes -
Replying to @rustlang
Yup, that's a good point, and a trick I've used myself. Would have been more clear if I had left off "struct" from the above and made it clear it's enums that are getting new possibilities - struct #[non_exhaustive] is much more about convenience and consistency.
1 reply 0 retweets 1 like
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.

