-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Milestone
Description
- I have searched open and closed issues and pull requests for duplicates, using these search terms:
- is:issue is:open Creating a new User instance using one of the values from user1
- is:issue is:open Listing 5-6
- I have checked the latest
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://doc.rust-lang.org/book/ch05-01-defining-structs.html
Description of the problem:
Listing 5-6 code reads:
fn main() {
// --snip--
let user2 = User {
active: user1.active,
username: user1.username,
email: String::from("another@example.com"),
sign_in_count: user1.sign_in_count,
};
}
Listing 5-6: Creating a new User instance using one of the values from user1
It seems to me that we we are copying all the fields from user1 into user2 and only changing one of them - email.
Suggested fix:
Maybe the description under the code should say:
Listing 5-6: Creating a new User instance using all but one of the values from user1