diff options
| author | Joshua Liebow-Feeser <joshlf@users.noreply.github.com> | 2022-03-09 13:53:16 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-09 13:53:16 -0800 |
| commit | b142720322155ddb5aa4cac8b01ab5633b4cc854 (patch) | |
| tree | 88a3ba863baf8e88e177564a70ca0050e406ca8f | |
| parent | 10dccdc7fcbdc64ee9efe2c1ed975ab8c1d61287 (diff) | |
| download | rust-b142720322155ddb5aa4cac8b01ab5633b4cc854.tar.gz rust-b142720322155ddb5aa4cac8b01ab5633b4cc854.zip | |
Document NonZeroXxx layout guarantees
Document that `NonZeroXxx` has the same layout and bit validity as `Xxx` with the exception of `0`.
| -rw-r--r-- | library/core/src/num/nonzero.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 1ebd1c58f2b..8b247daf8a7 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -34,6 +34,11 @@ 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. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] |
