Deriving Pod for arbitrary generic types
reinerp opened this issue · 1 comments
reinerp commented
If we were willing to break backwards compatibility, it would be possible to support deriving Pod
for arbitrary generic types.
The approach:
- extend
trait Pod
to includeconst POST_MONOMORPHISM_CHECKS_PASS: bool;
- the
derive(Pod)
instance puts its checks inside thisPOST_MONOMORPHISM_CHECKS_PASS
constant. Since this is a trait member, it is allowed to reference the generic types. - (the backwards incompatible part) require that any function that uses
T: Pod
to do some form of safe transmute ofT
must first doassert!(POST_MONOMORPHISM_CHECKS_PASS);
.
Lokathor commented
We might do this some day for version 2 (but that's far far in the future).