We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5989bf4 commit 73ada2dCopy full SHA for 73ada2d
library/core/src/option.rs
@@ -70,10 +70,18 @@
70
//! }
71
//! ```
72
//!
73
-//! This usage of [`Option`] to create safe nullable pointers is so
74
-//! common that Rust does special optimizations to make the
75
-//! representation of [`Option`]`<`[`Box<T>`]`>` a single pointer. Optional pointers
76
-//! in Rust are stored as efficiently as any other pointer type.
+//! # Representation
+//!
+//! Rust guarantees to optimise the following inner types such that an [`Option`] which contains
+//! them has the same size as a pointer:
77
78
+//! * `&T`
79
+//! * `&mut T`
80
+//! * `extern "C" fn`
81
+//! * [`num::NonZero*`]
82
+//! * [`ptr::NonNull<T>`]
83
+//! * `#[repr(transparent)]` struct around one of the types in this list.
84
+//! * [`Box<T>`]
85
86
//! # Examples
87
0 commit comments