diff --git a/src/enums/sizes.md b/src/enums/sizes.md index fa013c6b..5736914d 100644 --- a/src/enums/sizes.md +++ b/src/enums/sizes.md @@ -29,9 +29,12 @@ fn main() { * See the [Rust Reference](https://doc.rust-lang.org/reference/type-layout.html).
- -* `Option` is another example of tight packing. -* For [some types](https://doc.rust-lang.org/std/option/#representation), Rust guarantees that `size_of::()` equals `size_of::>()`. -* Zero-sized types allow for efficient implementation of `HashSet` using `HashMap` with `()` as the value. + +Key Points: + * Internally Rust is using a field (discriminant) to keep track of the enum variant. + * As a niche optimization an enum discriminant is merged with the pointer so that `Option<&Foo>` is the same size as `&Foo`. + * `Option` is another example of tight packing. + * For [some types](https://doc.rust-lang.org/std/option/#representation), Rust guarantees that `size_of::()` equals `size_of::>()`. + * Zero-sized types allow for efficient implementation of `HashSet` using `HashMap` with `()` as the value.