From 89f5c7459d0e02bab11ed49cb2726742308384de Mon Sep 17 00:00:00 2001 From: Frances Wingerter Date: Mon, 12 Aug 2024 15:14:19 -0400 Subject: [PATCH] box.md: clarify that box provides needed indirection for DSTs/recursive types the indirection is in different places for these two cases (inside the type for recursive types and outside it for DSTs), but fundamentally required for the same reason of providing a static size --- src/smart-pointers/box.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/smart-pointers/box.md b/src/smart-pointers/box.md index dbf91cd0e328..bed5b4043685 100644 --- a/src/smart-pointers/box.md +++ b/src/smart-pointers/box.md @@ -31,7 +31,8 @@ fn main() { [call methods from `T` directly on a `Box`](https://doc.rust-lang.org/std/ops/trait.Deref.html#more-on-deref-coercion). -Recursive data types or data types with dynamic sizes need to use a `Box`: +Recursive data types or data types with dynamic sizes cannot be stored inline +without a pointer indirection, which can be worked around using `Box`: ```rust,editable #[derive(Debug)]