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 `Pod` for structs where generics are used only as `PhantomData` #191

Open vadorovsky opened 1 year ago

vadorovsky commented 1 year ago

Currently, bytemuck disallows to derive Pod if the struct has any generics:

https://github.com/Lokathor/bytemuck/blob/8391afa876ba2e99dffb0c991cc7fa775287d106/derive/src/traits.rs#L55-L57

However, if generics are used only as PhantomData inside #[repr(C)] struct, that should be still OK. (I ended up doing unsafe impl bytemuck::Podmyself in such cases)

wdanilo commented 1 year ago

I believe this is duplicate of what I raised yesterday (at least both problems could be solved by the same thing): https://github.com/Lokathor/bytemuck/issues/190

Lokathor commented 1 year ago

I think a solution to 190 would solve this too but we can keep this issue open just in case.