Add example of struct update syntax

This commit is contained in:
laurens 2020-05-22 13:41:50 +02:00
parent 1dfa283017
commit ea1a37f9ef

View file

@ -18,4 +18,12 @@ fn build_user(email: String, username: String) -> User {
fn main() {
let user = build_user(String::from("Heisenberg"), String::from("mail@mail.com"));
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);
}