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

derive(CheckedBitPattern) should work on repr-stable enums with fields #166

Closed
RReverser opened this issue Jan 22, 2023 · 0 comments · Fixed by #171
Closed

derive(CheckedBitPattern) should work on repr-stable enums with fields #166

RReverser opened this issue Jan 22, 2023 · 0 comments · Fixed by #171

Comments

@RReverser
Copy link

repr(C), repr(i*) and repr(u*) enums with fields have had a stable layout for FFI for about 5 years now, and recently arbitrary enum discriminants on enums with fields were stabilized as well.

It would be great to support them in the CheckedBitPattern derive so that examples from that issue could be casted to/from bytes as expected, e.g.:

#[derive(Clone, Copy, CheckedBitPattern)]
#[repr(u8)]
enum Foo {
    A = 0,
    B { a: u16 } = 1,
    C { a: u32, b: u16 } = 2,
}
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

Successfully merging a pull request may close this issue.

1 participant