diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-06-01 11:29:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-01 11:29:44 +0200 |
| commit | f4d3f32f4529adc9709ee11fd062b49332d36096 (patch) | |
| tree | 4618d418ae4d7d1f67ffa7e3dc08997472c6a074 | |
| parent | 085691b137cd255b32c66a3aa843783fa7ead726 (diff) | |
| parent | 79575a1a8e55d767c63958f5970e6858b8e8e176 (diff) | |
| download | rust-f4d3f32f4529adc9709ee11fd062b49332d36096.tar.gz rust-f4d3f32f4529adc9709ee11fd062b49332d36096.zip | |
Rollup merge of #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.
| -rw-r--r-- | library/core/src/option.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs index cfb73ed0395..4e7afca6a49 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -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` |
