]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/struct-field-shorthand.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / structs-enums / struct-field-shorthand.rs
1 // run-pass
2 struct Foo {
3     x: i32,
4     y: bool,
5     z: i32
6 }
7
8 struct Bar {
9     x: i32
10 }
11
12 pub fn main() {
13     let (x, y, z) = (1, true, 2);
14     let a = Foo { x, y: y, z };
15     assert_eq!(a.x, x);
16     assert_eq!(a.y, y);
17     assert_eq!(a.z, z);
18
19     let b = Bar { x, };
20     assert_eq!(b.x, x);
21
22     let c = Foo { z, y, x };
23     assert_eq!(c.x, x);
24     assert_eq!(c.y, y);
25     assert_eq!(c.z, z);
26 }