bytemuck
bytemuck copied to clipboard
Address safety invariants in documentation
The safety documentation on AnyBitPattern mentions validity, but not safety.
From what I can tell an inhabited ZST with a trivially false safety invariant satisfies all the conditions listed (except the last, I guess).
mod foo {
/// # SAFETY
///
/// Sound APIs can assume that they will never observe values of this type
pub struct UnsafelyInhabited{
_priv: PhantomData<()>
}
pub fn explode(_ui: UnsafelyInhabited) {
unsafe {unreachable_unchecked()}
}
}
Fair point. the docs say "valid" when they should probably say something like "safe".