Skip to content
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

emit warning, if used on a private struct #6

Open
Luro02 opened this issue Jan 7, 2020 · 0 comments
Open

emit warning, if used on a private struct #6

Luro02 opened this issue Jan 7, 2020 · 0 comments

Comments

@Luro02
Copy link
Owner

Luro02 commented Jan 7, 2020

deriving ShortHand will increase the compile time and on internal types, it might be better to simply make all fields public. The problem with having fields public in a user facing api is, that a lot of things could break the api, for example adding a new field to a struct would break existing uses and therefore would require a version bump. This is not a problem in private apis.

A warning should be silenceable, but this is blocked on the stabilization of the diagnostic api. I think, that warning might be a very good way, to make the library author think about how this macro impacts performance. (yes compile times are currently a real issue and I think, that by having multiple dependencies using shorthand, this could become a real problem, because hundreds of functions have to be generated and maybe only a few are used?)

Every struct, that is not pub should be warned against

Note

This should only check the visibility of the entire struct and not the visibility attribute!

While we are at it, the macro should panic, if the visibility of a field is more, than the function visibility. Why bother using a getter/setter, when you could just modify the field itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant