cognitive-engineering-lab / rust-book

The Rust Programming Language: Experimental Edition
https://rust-book.cs.brown.edu
Other
504 stars 82 forks source link

Replace statement "Moved Heap Data Principle" wit "Box Deallocation Principle". #115

Closed jpnws closed 11 months ago

jpnws commented 11 months ago

Moved heap data principle: if a variable x moves ownership of heap data to another variable y, then x cannot be used after the move.

Box deallocation principle (fully correct): If a variable owns a box, when Rust deallocates the variable's frame, then Rust deallocates the box's heap memory.

The moved heap data principle emphasizes the fact that we cannot use a variable that was moved.

The box deallocation principle emphasizes that a variable's heap memory gets deallocated if the variable owned the box (pointing to the heap memory).

The context of this paragraph is in line with the Box Deallocation Principle.

willcrichton commented 11 months ago

Good catch, thanks!