Auto merge of #94786 - joshlf:patch-5, r=dtolnay

Document NonZeroXxx layout guarantees

Document that `NonZeroXxx` has the same layout and bit validity as `Xxx` with the exception of `0`.
This commit is contained in:
bors 2023-04-05 01:09:59 +00:00
commit f98a271814

View File

@ -34,6 +34,13 @@ macro_rules! nonzero_integers {
/// use std::mem::size_of;
#[doc = concat!("assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int), ">());")]
/// ```
///
/// # Layout
///
#[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")]
/// with the exception that `0` is not a valid instance.
#[doc = concat!("`Option<", stringify!($Ty), ">` is guaranteed to be compatible with `", stringify!($Int), "`,")]
/// including in FFI.
#[$stability]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]