Lokathor / bytemuck

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

derive(Zeroable) on fieldful enums and repr(C) enums #257

Closed zachs18 closed 2 months ago

zachs18 commented 4 months ago

Closes #230.

Allows deriving Zeroable on enums where:

  1. The enum is #[repr(Int)], #[repr(C)], or #[repr(C, Int)],
  2. There is a variant with discriminant 0,
  3. The variant with discriminant 0 is either fieldless, or all of its fields are Zeroable.

Also allows using the "perfect derive with additional bounds" from #196 for Zeroable on enums, where the fields for the "perfect derive" are from the variant with discriminant 0 (see the MyOption example on line 189 of derive/src/lib.rs).

Internal changes:

Lokathor commented 1 month ago

Sorry about the delay, bytemuck_derive-1.8.0 should be out now