@@ -313,18 +313,18 @@ field which it contains; in the case of `Option<T>`, the payload has
313313type `T`.
314314
315315**Definition.** In some cases, the payload type may contain illegal
316- values, which are called **niches**. For example, a value of type `&T`
317- may never be `NULL`, and hence defines a niche consisting of the
316+ values, which are called **[ niches][niche] **. For example, a value of type `&T`
317+ may never be `NULL`, and hence defines a [ niche] consisting of the
318318bitstring `0`. Similarly, the standard library types [`NonZeroU8`]
319319and friends may never be zero, and hence also define the value of `0`
320- as a niche.
320+ as a [ niche] .
321321
322322[`NonZeroU8`]: https://doc.rust-lang.org/std/num/struct.NonZeroU8.html
323323
324- The niche values must be disjoint from the values allowed by the validity
324+ The [ niche] values must be disjoint from the values allowed by the validity
325325invariant. The validity invariant is, as of this writing, the current active
326326discussion topic in the unsafe code guidelines process. [rust-lang/rust#60300]
327- specifies that the following types have at least one niche (the all-zeros
327+ specifies that the following types have at least one [ niche] (the all-zeros
328328bit-pattern):
329329
330330* `&T`
@@ -334,15 +334,15 @@ bit-pattern):
334334* `core::ptr::NonNull<T>`
335335* `#[repr(transparent)] struct` around one of the types in this list.
336336
337- **Option-like enums where the payload defines at least one niche value
337+ **Option-like enums where the payload defines at least one [ niche] value
338338are guaranteed to be represented using the same memory layout as their
339339payload.** This is called **discriminant elision**, as there is no
340- explicit discriminant value stored anywhere. Instead, niche values are
340+ explicit discriminant value stored anywhere. Instead, [ niche] values are
341341used to represent the unit variant.
342342
343343The most common example is that `Option<&u8>` can be represented as an
344344nullable `&u8` reference -- the `None` variant is then represented
345- using the niche value zero. This is because a valid `&u8` value can
345+ using the [ niche] value zero. This is because a valid `&u8` value can
346346never be zero, so if we see a zero value, we know that this must be
347347`None` variant.
348348
@@ -376,6 +376,8 @@ enum Enum2<T> {
376376}
377377```
378378
379+ [niche]: ../glossary.html#niche
380+
379381## Unresolved questions
380382
381383### Layout of single variant enums
0 commit comments