Skip to content

ch15-02-deref.md#using-boxt-like-a-reference seems misleading #1581

Closed
rust-lang/rust
#93532
@phyxdown

Description

@phyxdown

Book 2018-edition is amazing.

Yet in ch15-02-deref.md#using-boxt-like-a-reference, the first sentence

(The only difference between Listing 15-7 and Listing 15-6 is that here we set y to be an instance of a box pointing to the value in x rather than a reference pointing to the value of x.)

seems a bit misleading.

Box::new allocates memory on the heap and then places x into it while x is on stack. The instance of box is pointing to a value in a newly allocated heap memory, not in x.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions