Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.1 Misleading description of what happens when Creating Instances from Other Instances #119

Open
djlondon opened this issue Aug 22, 2023 · 1 comment

Comments

@djlondon
Copy link

The sentence here describing what happens to user1 after it's used to created user2 is inaccurate:

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

This suggests that the entire user1 struct is now unusable, but it is not:

let user1 = User {
    email: String::from("[email protected]"),
    username: String::from("someusername123"),
    active: true,
    sign_in_count: 1,
};

let user2 = User {
    email: String::from("[email protected]"),
    ..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

@masterchess33
Copy link

Agree. The original sentence is misleading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants