Skip to content

Commit

Permalink
Rollup merge of rust-lang#51396 - SimonSapin:option-nonzero-layout, r…
Browse files Browse the repository at this point in the history
…=SimonSapin

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

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

Note that `ptr::NonNull<T>` already documents a similar guarantee.
  • Loading branch information
Mark-Simulacrum authored Jun 8, 2018
2 parents 6abaf4e + 5c7ca77 commit b1a6db2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>());
/// ```
Expand Down

0 comments on commit b1a6db2

Please sign in to comment.