Refining Ch05.

This commit is contained in:
rust-lang.xfoss.com
2023-12-14 13:46:39 +08:00
parent 152b836c96
commit 79ad726f36
2 changed files with 41 additions and 24 deletions

View File

@@ -6,12 +6,18 @@ struct User {
}
fn main() {
let mut user1 = User {
let user1 = User {
active: true,
username: String::from("someusername123"),
email: String::from("someone@example.com"),
sign_in_count: 1,
}
};
user1.email = String::from("anotheremail@example.com");
let user2 = User {
email: String::from("another@example.com"),
..user1
};
println! ("{}", user2.email);
}