File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,6 @@ fn main() {
2727 let age = 39;
2828 let avery = Person { name, age };
2929 describe(&avery);
30-
31- let jackie = Person { name: String::from("Jackie"), ..avery };
32- describe(&jackie);
3330}
3431```
3532
@@ -49,8 +46,22 @@ Key Points:
4946 not important.
5047- If you already have variables with the right names, then you can create the
5148 struct using a shorthand.
52- - The syntax ` ..avery ` allows us to copy the majority of the fields from the old
53- struct without having to explicitly type it all out. It must always be the
54- last element.
49+
50+ ## More to Explore
51+
52+ - You can also demonstrate the struct update syntax here:
53+
54+ ``` rust,ignore
55+ let jackie = Person { name: String::from("Jackie"), ..avery };
56+ ```
57+
58+ - It allows us to copy the majority of the fields from the old struct without
59+ having to explicitly type it all out. It must always be the last element.
60+
61+ - It is mainly used in combination with the ` Default ` trait.
62+
63+ - We will talk about struct update syntax in more detail on the slide on the
64+ ` Default ` trait, so we don't need to talk about it here unless students ask
65+ about it.
5566
5667</details >
You can’t perform that action at this time.
0 commit comments