Pod safety documentation change

The previous requirements were incorrect because I misunderstood how `repr(packed)` actually means `repr(Rust, packed)` rather than `repr(C, packed)` as I first assumed.
Closes https://github.com/Lokathor/bytemuck/issues/14
This commit is contained in:
Lokathor 2020-01-29 01:08:14 -07:00
parent 481c6879ec
commit f5d5523f77

View File

@ -23,7 +23,9 @@ use super::*;
/// middle, and also no `#[repr(C)] struct Foo(u16, u8)`, which has padding on
/// the end).
/// * The type needs to have all fields also be `Pod`.
/// * The type needs to be `repr(C)`, `repr(transparent)`, or `repr(packed)`.
/// * The type needs to be `repr(C)` or `repr(transparent)`. In the case of
/// `repr(C)`, the `packed` and `align` repr modifiers can be used as long as
/// all other rules end up being followed.
pub unsafe trait Pod: Zeroable + Copy + 'static {}
unsafe impl Pod for () {}