Skip to content

Commit f98a271

Browse files
committed
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`.
2 parents 6032700 + 9a3346b commit f98a271

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/num/nonzero.rs

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ macro_rules! nonzero_integers {
3434
/// use std::mem::size_of;
3535
#[doc = concat!("assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int), ">());")]
3636
/// ```
37+
///
38+
/// # Layout
39+
///
40+
#[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")]
41+
/// with the exception that `0` is not a valid instance.
42+
#[doc = concat!("`Option<", stringify!($Ty), ">` is guaranteed to be compatible with `", stringify!($Int), "`,")]
43+
/// including in FFI.
3744
#[$stability]
3845
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3946
#[repr(transparent)]

0 commit comments

Comments
 (0)