Add example of struct update syntax
This commit is contained in:
parent
1dfa283017
commit
ea1a37f9ef
1 changed files with 14 additions and 6 deletions
|
|
@ -18,4 +18,12 @@ fn build_user(email: String, username: String) -> User {
|
||||||
fn main() {
|
fn main() {
|
||||||
let user = build_user(String::from("Heisenberg"), String::from("mail@mail.com"));
|
let user = build_user(String::from("Heisenberg"), String::from("mail@mail.com"));
|
||||||
println!("Hello to the User: {:?}!", user);
|
println!("Hello to the User: {:?}!", user);
|
||||||
|
|
||||||
|
let user2 = User {
|
||||||
|
username: String::from("Jesse"),
|
||||||
|
email: String::from("mail@mail.com"),
|
||||||
|
..user
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Hello to the User: {:?}!", user2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue