File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 7070//! }
7171//! ```
7272//!
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.
73+ //! # Representation
74+ //!
75+ //! Rust guarantees to optimise the following inner types such that an [`Option`] which contains
76+ //! 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>`]
7785//!
7886//! # Examples
7987//!
You can’t perform that action at this time.
0 commit comments