From aa316544c3e4ab358216e373de50c993531b2547 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Thu, 9 Feb 2023 12:49:00 -0800 Subject: [PATCH] Update box-recursive.md (#360) --- src/std/box-recursive.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/std/box-recursive.md b/src/std/box-recursive.md index 157c7e3b..02ec67ef 100644 --- a/src/std/box-recursive.md +++ b/src/std/box-recursive.md @@ -32,10 +32,12 @@ fn main() {
-If the `Box` was not used here and we attempted to embed a `List` directly into the `List`, +* 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 +* `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. + +* Remove the `Box` in the List definition and show the compiler error. `Recursive with indirection` is a hint you might want to use a Box or reference of some kind, instead of storing a value directly.