-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Milestone
Description
let user2 = User {
email: String::from("[email protected]"),
username: String::from("anotherusername567"),
active: user1.active,
sign_in_count: user1.sign_in_count,
};
let user2 = User {
email: String::from("[email protected]"),
username: String::from("anotherusername567"),
..user1
};
Someone working through this book asked me "should I be choosing to order my fields in the struct in a way that makes the most sense for struct update syntax?", which didn't quite make sense to me until I realized that the code gives the impression that struct update syntax can only fill in the last fields of a struct.
It may be worth picking different fields in the example, or explicitly clarifying this. I'm not sure how to do this with picking different fields without changing the motivation there, though.
Note: It was clear to this person that you don't need to specify fields in order for normal struct init syntax, it was specifically this context where they got confused.