Skip to content

Commit f5118a5

Browse files
committed
Clarify and add guarantee about transmute.
1 parent 73ada2d commit f5118a5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/core/src/option.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@
7272
//!
7373
//! # Representation
7474
//!
75-
//! Rust guarantees to optimise the following inner types such that an [`Option`] which contains
76-
//! them has the same size as a pointer:
75+
//! Rust guarantees to optimize the following types `<T>` such that an
76+
//! [`Option<T>`] has the same size as `T`:
7777
//!
78+
//! * [`Box<T>`]
7879
//! * `&T`
7980
//! * `&mut T`
8081
//! * `extern "C" fn`
8182
//! * [`num::NonZero*`]
8283
//! * [`ptr::NonNull<T>`]
8384
//! * `#[repr(transparent)]` struct around one of the types in this list.
84-
//! * [`Box<T>`]
85+
//!
86+
//! For the above cases, it is guaranteed that one can use [`mem::transmute`]
87+
//! between `T` and `Option<T>` and vice versa.
8588
//!
8689
//! # Examples
8790
//!

0 commit comments

Comments
 (0)