You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-27 11:08:45 +02:00
Reduce references to niche optimization (#2385)
Niche optimization is currently mentioned in three places: - Enums (User-Defined Types, Day 1 Afternoon) - Option (Standard Library Types, Day 2 Afternoon) - Box (Smart Pointers, Day 3 Morning) This is a tricky thing to get right, and it was just in the speaker notes in each place. #1820 will introduce a fuller explanation. Fixes #1820.
This commit is contained in:
committed by
GitHub
parent
a699430741
commit
d9e3ad9e63
@ -30,7 +30,11 @@ fn main() {
|
||||
None.
|
||||
- It's common to `unwrap`/`expect` all over the place when hacking something
|
||||
together, but production code typically handles `None` in a nicer fashion.
|
||||
- The niche optimization means that `Option<T>` often has the same size in
|
||||
memory as `T`.
|
||||
|
||||
- The "niche optimization" means that `Option<T>` often has the same size in
|
||||
memory as `T`, if there is some representation that is not a valid value of T.
|
||||
For example, a reference cannot be NULL, so `Option<&T>` automatically uses
|
||||
NULL to represent the `None` variant, and thus can be stored in the same
|
||||
memory as `&T`.
|
||||
|
||||
</details>
|
||||
|
Reference in New Issue
Block a user