Description of the problem:
In the linked section, there is this sentence:
In this program, we call set_to_max with two rectangles r1 and r2. self is a mutable reference to r1 and other is a move of r2. After calling self.max(other), the max method consumes ownership of both rectangles. When max returns, Rust deallocates both strings "r1" and "r2" in the heap. Notice the problem: at the location L2, self is supposed to be readable and writable. However, (self).name (actually r1.name) has been deallocated.
Actually at L2, shouldn't *self and other be dropped at the end of the Rectangle.max function? In the diagram, L2 shows that r1 is intact, just that the name is undefined.
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch05-03-method-syntax.html#good-moves-and-bad-moves
Description of the problem: In the linked section, there is this sentence:
Actually at L2, shouldn't
*self
andother
be dropped at the end of theRectangle.max
function? In the diagram, L2 shows thatr1
is intact, just that the name is undefined.Suggested fix: Grey out
r1
too.