Skip to content

Commit f4d3f32

Browse files
Rollup merge of rust-lang#85826 - jsha:npo, r=joshtriplett
Mention "null pointer optimization" in option docs. I had seen people discuss "null pointer optimization," but when I tried to find official documentation (using Google), the `std::option` page didn't show up, because it doesn't use that term. Hopefully adding the term will help others find it in the future.
2 parents 085691b + 79575a1 commit f4d3f32

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/option.rs

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
//! * [`ptr::NonNull<U>`]
8484
//! * `#[repr(transparent)]` struct around one of the types in this list.
8585
//!
86+
//! This is called the "null pointer optimization" or NPO.
87+
//!
8688
//! It is further guaranteed that, for the cases above, one can
8789
//! [`mem::transmute`] from all valid values of `T` to `Option<T>` and
8890
//! from `Some::<T>(_)` to `T` (but transmuting `None::<T>` to `T`

0 commit comments

Comments
 (0)