Skip to content

Commit

Permalink
Clarify and add guarantee about transmute.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltratt committed Aug 12, 2020
1 parent 73ada2d commit f5118a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@
//!
//! # Representation
//!
//! Rust guarantees to optimise the following inner types such that an [`Option`] which contains
//! them has the same size as a pointer:
//! Rust guarantees to optimize the following types `<T>` such that an
//! [`Option<T>`] has the same size as `T`:
//!
//! * [`Box<T>`]
//! * `&T`
//! * `&mut T`
//! * `extern "C" fn`
//! * [`num::NonZero*`]
//! * [`ptr::NonNull<T>`]
//! * `#[repr(transparent)]` struct around one of the types in this list.
//! * [`Box<T>`]
//!
//! For the above cases, it is guaranteed that one can use [`mem::transmute`]
//! between `T` and `Option<T>` and vice versa.
//!
//! # Examples
//!
Expand Down

0 comments on commit f5118a5

Please sign in to comment.