Lokathor / bytemuck

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

allow deriving `CheckedBitPattern` for enums with fields #171

Closed Freax13 closed 1 year ago

Freax13 commented 1 year ago

This pr consist of two parts:

  1. Miscellaneous improvements to the internal Representation type
  2. The implementation for deriving CheckedBitPattern for enums with fields

The following representations have a stable type layout for enums with fields and are now supported in the CheckedBitPattern derive macro:

The representations are specified at https://doc.rust-lang.org/reference/type-layout.html.

Closes #166

fu5ha commented 1 year ago

Thanks for the PR! Just noting it will probably take me a while longer to get around to reviewing it, sorry about that!

Freax13 commented 1 year ago

Ping @fu5ha @Lokathor

Freax13 commented 1 year ago

I just rebased this onto the latest main branch.

Lokathor commented 1 year ago

I gave fusha a poke on discord and she said she'd try to get to this soon.

Freax13 commented 1 year ago

Thanks for the patience on my review. Nice work! Hope you don't mind I took the liberty of changing some variable names and adding some comments to the new derives as I went through and tried to verify them. As far as I can tell it all checks out :)

Sure, thanks, your changes look good to me.

Could you update the doc comment on the checked bit pattern proc macro derive fn in the derive crate lib.rs to reflect the new capabilities and restrictions on enums with fields? Other than that, I think this seems ready to merge.

Done. I noticed that the description was already out of date even before this pr, so I also updated the parts no related to enums.

Freax13 commented 7 months ago

@Lokathor Could please you create a new release for bytemuck_derive? Thanks!

Lokathor commented 7 months ago

Ahhhh, sorry about that. Next time definitely don't feel bad about pinging me sooner if you need to.

bytemuck_derive-1.6.0 is out now!