1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-05 03:58:45 +02:00

Update box-recursive.md (#241)

* Update box-recursive.md

Adding Speaker Notes. This is a high-level guideline what to say, so we can settle on one explanation and review it.
This may be very obvious with the background in some languages, but be very non-obvious in languages that always
use references and never embed structs into structs.

* Fix wording

Co-authored-by: Andrew Walbran <qwandor@google.com>
This commit is contained in:
Igor Petruk 2023-01-23 12:54:06 +00:00 committed by GitHub
parent 6b6c553789
commit 91487289d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,3 +30,12 @@ fn main() {
`- - - - - - - - - - - - -' '- - - - - - - - - - - - - - - - - - - - - - - -' `- - - - - - - - - - - - -' '- - - - - - - - - - - - - - - - - - - - - - - -'
``` ```
<details>
If the `Box` was not used here and we attempted to embed a `List` directly into the `List`,
the compiler would not compute a fixed size of the struct in memory, it would look infinite.
`Box` solves this problem as it has the same size as a regular pointer and just points at the next
element of the `List` in the heap.
</details>