Field init shorthand

In older Rust, when initializing a struct, you must always give the full set of key: value pairsfor its fields:
2. #![allow(unused_variables)]
3. fn main() {
4. struct Point {
5. x: i32,
6. y: i32,
7. }
9. let a = 5;
10. let b = 6;
12. let p = Point {
13. x: a,
14. y: b,
15. };
16. }
However, often these variables would have the same names as the fields. So you'd end upwith code that looks like this:
1. let p = Point {
2. x: x,
3. y: y,
4. };
Now, if the variable is of the same name, you don't have to write out both, just write out the key:
2. #![allow(unused_variables)]
3. fn main() {
4. struct Point {
5. x: i32,
6. y: i32,
7. }
9. let x = 5;
10. let y = 6;
12. // new
13. let p = Point {
14. x,
15. y,
16. };
17. }
