Lokathor / bytemuck

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

Allow deriving `Zeroable` for enums which are `#[repr(u32, i8, etc..)]` #230

Open ARitz-Cracker opened 6 months ago

ARitz-Cracker commented 6 months ago

If an enum is explicitly defined in a manner where "0" is a valid variant, and all the payloads of the 0 variant are zeroable, then it concludes that the enum is safely zeroable.

ARitz-Cracker commented 6 months ago

Additionally (though this may be a separate issue) an enum which is #[repr(u8)] and has all 256 variants explicitly defined can safely implement Pod.

Lokathor commented 6 months ago

That all sounds right to me.