-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should #[non_exhaustive] be advised over private members for extensibility? #132
Comments
|
That said, how do you imagine it. Do you want to keep both variants in the repo and state their use cases explicitly (link between them, improve doc to state both)? #135 replaces it now, which I'm not sure of if there is still at least one scenario where it will be used? |
An obvious scenario where it will be used is for compatibility with MSRV (Minimum supported Rust version).
I would keep both variants in the same file, if it is necessary to keep the old approach. Maybe the file could be called "Fields extensibility" and then we discuss both the approaches, first the new one and then we also write the old one (again, if we decide it is necessary), by explicitly saying it is less idiomatic than using |
I'm a third person here, but I would probably create a "Legacy" category with patterns which are outdated/replaced with better alternatives, and then create cross-links on both approaches (maybe with MSRV mentioned etc.)
|
Mmm..I don't dislike the idea of a "legacy" category :) |
I think something like:
Could be then a nice build up rather than mentioning legacy in each category. |
I agree! Of course for now there will be only the |
This would be the question if it's worth to mention then and should be added. For now I think the |
#[non_exhaustive]
attribute on Rust reference.I believe
#[non_exhaustive]
emerged as a better solution to the same problem and private members are an artifact from the rime before it. Still it seems there are a few differences.From what I can understand, the attribute has three primary differences compared to private members:
!
). It is not mentioned in the book.Overall I consider the new approach as much superior (less boilerplate, better consistency), the old one should be deprecated and used only when very specific semantics is required (e. g. module-level non-exhaustiveness vs crate-level).
The text was updated successfully, but these errors were encountered: