Lokathor / bytemuck

A crate for mucking around with piles of bytes
https://docs.rs/bytemuck
Apache License 2.0
740 stars 80 forks source link

`Contiguous` should be derivable for enums when only the first discriminant is an expression #266

Open ds84182 opened 3 months ago

ds84182 commented 3 months ago

This is currently rejected because it isn't an integer literal.

Example:

const MY_CONST: u8 = 123;
#[derive(Copy, Clone, bytemuck::Contiguous)]
#[repr(u8)]
enum Foo {
    A = MY_CONST,
    B,
    C,
}
Lokathor commented 3 months ago

Yes, this sounds right.

As usual for proc-macros, I'm not interested in doing this myself, but if someone else submits the PR then we can get it handled and published.