| 1 | interface Rect { |
| 2 | width u32 |
| 3 | height u32 |
| 4 | } |
| 5 | |
| 6 | struct Square { |
| 7 | side u32 |
| 8 | width u32 |
| 9 | height u32 |
| 10 | } |
| 11 | |
| 12 | fn test_main() { |
| 13 | squares := [Square{ |
| 14 | side: 5 |
| 15 | width: 5 |
| 16 | height: 5 |
| 17 | }] |
| 18 | rects := squares.map(Rect(it)) |
| 19 | |
| 20 | assert rects.str() == '[Rect(Square{ |
| 21 | side: 5 |
| 22 | width: 5 |
| 23 | height: 5 |
| 24 | })]' |
| 25 | } |
| 26 | |
| 27 | fn test_fixed_array() { |
| 28 | squares := [Square{ |
| 29 | side: 5 |
| 30 | width: 5 |
| 31 | height: 5 |
| 32 | }]! |
| 33 | rects := squares.map(Rect(it)) |
| 34 | } |
| 35 |