You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of the problem:
On the last memory diagram (Added the mut keyword to the let-binding), rect do not lose Read permission.
For instance this program is valid :
structRectangle{width:u32,height:u32,}implRectangle{fnset_width(&mutself,width:u32){self.width = width;}}fnmain(){// Added the mut keyword to the let-bindingletmut rect = Rectangle{width:0,height:0,};
rect.set_width(1);// this is now oklet rect_ref = ▭println!("{} {}",rect.width,rect.height);println!("{} {}",rect_ref.width,rect_ref.height);}
Suggested fix:
Do not strike Read permission for rect, rect.width and rect.height.
The text was updated successfully, but these errors were encountered:
URL to the section(s) of the book with this problem:
https://rust-book.cs.brown.edu/ch05-03-method-syntax.html#reads-and-writes-with-self-and-mut-self
Description of the problem:
On the last memory diagram (Added the mut keyword to the let-binding),
rect
do not lose Read permission.For instance this program is valid :
Suggested fix:
Do not strike Read permission for
rect
,rect.width
andrect.height
.The text was updated successfully, but these errors were encountered: