-
Notifications
You must be signed in to change notification settings - Fork 36
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
annotation to not create a "new" method #114
Comments
It is generally recommended that if you are going to make a public-facing API based on an Ouroboros struct then you wrap the self-referencing struct in your own struct and add the methods you want to define to your struct. (This is called the 'newtype' pattern and it is fairly common in Rust.) |
that reccomendation doesn't appear anywhere in the documentation, and in fact the visibility rules seem to imply you can use it directly on a public struct. |
The visibility rules are there so that you can use it at whatever level you need in your library. It is intended that you will never use it on a public struct that users of your library would interact with, but since there is no detectable difference between "pub in a module which is not itself public" and "pub so that everyone who uses this library can see this struct," the macro cannot enforce this recommendation. |
then that intent should be documented.
|
i have a self-referential struct and i would like to name its public constructor "new" for consistency with other types in my crate, however, due to the auto-generated method created by ouroboros, this is not possible.
The text was updated successfully, but these errors were encountered: