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
Allow repr(transparent)
to be used generically in derive(Pod)
#139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea seems good to me, will defer to @danielhenrymantilla on implementation review :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new add_trait_marker
LGTM ✅; just note that there are a bunch of rustfmt
-induced changes as well in that last commit
Whoops, I guess I just run rustfmt before commit by instinct nowadays. |
rustfmt is no big deal, i do the same thing. |
Released |
…kathor#139) * Enabled transparent generics * Move trait checks to implementation block * Replace add_trait_marker impl
My current use case is this:
However, the current
derive
system only allows forrepr(packed)
to be used with generics, despite the fact that, by definition,repr(transparent)
contains no padding. This PR adds the option forrepr(transparent)
to be used in this way.I also moved to checks on the actual implementation to the
impl
block rather than being static, so thatMyNewtype
can also be used in the non-Pod
case. I've verified that this works for my use case.