From e3b4b6a5c7684be1d49724515ded6173f611f019 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Thu, 9 Feb 2023 12:55:19 -0800 Subject: [PATCH] Update box.md (#363) --- src/std/box.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/std/box.md b/src/std/box.md index 504316f6..38ecd99c 100644 --- a/src/std/box.md +++ b/src/std/box.md @@ -31,7 +31,9 @@ from `T` directly on a `Box`][2].
-* `Box` is like `std::unique_ptr` in C++. -* In the above example, you can even leave out the `*` in the `println!` statement thanks to `Deref`. - +* `Box` is like `std::unique_ptr` in C++. +* In the above example, you can even leave out the `*` in the `println!` statement thanks to `Deref`. +* A `Box` can be useful when you: + * have a type whose size that can't be known at compile time, but the Rust compiler wants to know an exact size. + * want to transfer ownership of a large amount of data. To avoid copying large amounts of data on the stack, instead store the data on the heap in a `Box` so only the pointer is moved.