mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2026-08-22 14:13:28 +08:00
Refining Ch05.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user