diff --git a/src/user-defined-types/named-structs.md b/src/user-defined-types/named-structs.md index 34b56b5f3763..0db4d73f6820 100644 --- a/src/user-defined-types/named-structs.md +++ b/src/user-defined-types/named-structs.md @@ -27,9 +27,6 @@ fn main() { let age = 39; let avery = Person { name, age }; describe(&avery); - - let jackie = Person { name: String::from("Jackie"), ..avery }; - describe(&jackie); } ``` @@ -49,8 +46,20 @@ Key Points: not important. - If you already have variables with the right names, then you can create the struct using a shorthand. -- The syntax `..avery` allows us to copy the majority of the fields from the old - struct without having to explicitly type it all out. It must always be the - last element. + +## More to Explore + +- You can also demonstrate the struct update syntax here: + + ```rust,ignore + let jackie = Person { name: String::from("Jackie"), ..avery }; + ``` + +- It allows us to copy the majority of the fields from the old struct without + having to explicitly type it all out. It must always be the last element. + +- It is mainly used in combination with the `Default` trait. We will talk about + struct update syntax in more detail on the slide on the `Default` trait, so we + don't need to talk about it here unless students ask about it.