Open djlondon opened 1 year ago
The sentence here describing what happens to user1 after it's used to created user2 is inaccurate:
user1
user2
In this example, we can no longer use user1 after creating user2 because the String in the username field of user1 was moved into user2
String
username
This suggests that the entire user1 struct is now unusable, but it is not:
let user1 = User { email: String::from("someone@example.com"), username: String::from("someusername123"), active: true, sign_in_count: 1, }; let user2 = User { email: String::from("another@example.com"), ..user1 }; println!("{} {}", user1.active, user1.email); // user1 is still usable
playground
I think a better description would be:
In this example, we can no longer use user1.username after creating user2 because the String in the username field of user1 was moved into user2
user1.username
Agree. The original sentence is misleading.
The sentence here describing what happens to
user1
after it's used to createduser2
is inaccurate:This suggests that the entire
user1
struct is now unusable, but it is not:playground
I think a better description would be: