Skip to content

Commit

Permalink
Rollup merge of #85826 - jsha:npo, r=joshtriplett
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GuillaumeGomez authored Jun 1, 2021
2 parents 085691b + 79575a1 commit f4d3f32
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
//! * [`ptr::NonNull<U>`]
//! * `#[repr(transparent)]` struct around one of the types in this list.
//!
//! This is called the "null pointer optimization" or NPO.
//!
//! It is further guaranteed that, for the cases above, one can
//! [`mem::transmute`] from all valid values of `T` to `Option<T>` and
//! from `Some::<T>(_)` to `T` (but transmuting `None::<T>` to `T`
Expand Down

0 comments on commit f4d3f32

Please sign in to comment.