Rollup merge of #51396 - SimonSapin:option-nonzero-layout, r=SimonSapin

Make the size of Option<NonZero*> a documented guarantee.

Closes #49137, the tracking issue for `NonZero*`, as this was the last remaining open question.

Note that `ptr::NonNull<T>` already documents a similar guarantee.
This commit is contained in:
Mark Rousskov 2018-06-08 17:21:04 -06:00 committed by GitHub
commit b1a6db2833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -39,10 +39,10 @@ macro_rules! nonzero_integers {
$(
/// An integer that is known not to equal zero.
///
/// This may enable some memory layout optimization such as:
/// This enables some memory layout optimization.
/// For example, `Option<NonZeroU32>` is the same size as `u32`:
///
/// ```rust
/// # #![feature(nonzero)]
/// use std::mem::size_of;
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
/// ```