From 91487289d26a74c26ebdbb02501f5ba8a8fb65cc Mon Sep 17 00:00:00 2001 From: Igor Petruk Date: Mon, 23 Jan 2023 12:54:06 +0000 Subject: [PATCH] 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 --- src/std/box-recursive.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/std/box-recursive.md b/src/std/box-recursive.md index 75e616b1..157c7e3b 100644 --- a/src/std/box-recursive.md +++ b/src/std/box-recursive.md @@ -30,3 +30,12 @@ fn main() { `- - - - - - - - - - - - -' '- - - - - - - - - - - - - - - - - - - - - - - -' ``` +
+ +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. + +