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
Line: let b = User { age: 1, ..a };
Shows permissions for "..a" as no-read (orange circle empty) and not owner (red-circle empty). At that point, would not a still be the owner and also have read access?
Or am I interpreting the empty circles incorrectly and, if so, are they documented somewhere that I have missed?
Thanks
struct User {
name : String,
age : i32,
}
fn main() {
let mut a = User { name: String::from("Jeff"), age: 2 };
a.age += 1;
let b = User { age: 1, ..a };
a.age += 1;
println!("{} {}", b.name, b.age);
}
The text was updated successfully, but these errors were encountered:
An empty circle is best interpreted as "the read (R) permission is required, but it's missing." Exchange "read" for "write" or "own" depending on which color it is. The circles also expand to the permission character if you hover over them. The most thorough explanation of the diagrams is our chapter on References and Borrowing.
However, the code provided does show a bug! We didn't have a test for struct update syntax and it's showing the permissions on aafter the move, not before :(
Line: let b = User { age: 1, ..a };
Shows permissions for "..a" as no-read (orange circle empty) and not owner (red-circle empty). At that point, would not a still be the owner and also have read access?
Or am I interpreting the empty circles incorrectly and, if so, are they documented somewhere that I have missed?
Thanks
The text was updated successfully, but these errors were encountered: