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 include const POST_MONOMORPHISM_CHECKS_PASS: bool;
the derive(Pod) instance puts its checks inside this POST_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 of T must first do assert!(POST_MONOMORPHISM_CHECKS_PASS);.
If we were willing to break backwards compatibility, it would be possible to support deriving
Pod
for arbitrary generic types.The approach:
trait Pod
to includeconst POST_MONOMORPHISM_CHECKS_PASS: bool;
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.T: Pod
to do some form of safe transmute ofT
must first doassert!(POST_MONOMORPHISM_CHECKS_PASS);
.