Skip to content

Commit 9148728

Browse files
igor-petrukqwandor
andauthored
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>
1 parent 6b6c553 commit 9148728

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/std/box-recursive.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ fn main() {
3030
`- - - - - - - - - - - - -' '- - - - - - - - - - - - - - - - - - - - - - - -'
3131
```
3232

33+
<details>
34+
35+
If the `Box` was not used here and we attempted to embed a `List` directly into the `List`,
36+
the compiler would not compute a fixed size of the struct in memory, it would look infinite.
37+
38+
`Box` solves this problem as it has the same size as a regular pointer and just points at the next
39+
element of the `List` in the heap.
40+
41+
</details>

0 commit comments

Comments
 (0)