From 86289b481467a3853409d3eacc7f3607dba89ee1 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Tue, 12 Dec 2023 18:29:50 +0200 Subject: [PATCH] Remove an incorrect note (#1580) People are often confused by this: the fact that we can remove the `*` in the `println!()` is not because the compiler auto-derefs here (it does not), but because `Display` is implemented for `&T where T: Display` (a blanket implementation). --- src/smart-pointers/box.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/smart-pointers/box.md b/src/smart-pointers/box.md index 8e596892..0c833b52 100644 --- a/src/smart-pointers/box.md +++ b/src/smart-pointers/box.md @@ -60,7 +60,6 @@ fn main() {
* `Box` is like `std::unique_ptr` in C++, except that it's guaranteed to be not null. -* 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.