Hacker News new | ask | show | jobs
by gfs 2370 days ago
Can somebody elaborate on the #[non_exhaustive] use case inside a private struct? Wouldn't a separate crate not be able to use the struct if it was in another crate?
2 comments

The point is that the struct is public, and the fields are public, but users of the crate cannot directly create a new instance of the struct (without going through a function call in the module). This allows users to access the struct fields, but they cannot do any operations that would break if a new field is introduced.
I think `Foo` and `Bar` are supposed to be public, otherwise the example doesn't make sense.