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

Deriving Pod for arbitrary generic types #222

Open
reinerp opened this issue Jan 28, 2024 · 1 comment
Open

Deriving Pod for arbitrary generic types #222

reinerp opened this issue Jan 28, 2024 · 1 comment

Comments

@reinerp
Copy link

reinerp commented Jan 28, 2024

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);.
@Lokathor
Copy link
Owner

We might do this some day for version 2 (but that's far far in the future).

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

No branches or pull requests

2 participants