| 1 | struct Aa { |
| 2 | sub Bb |
| 3 | } |
| 4 | |
| 5 | struct AaWithAliasType { |
| 6 | sub Bb |
| 7 | } |
| 8 | |
| 9 | type AliasType = Bb |
| 10 | |
| 11 | struct Bb { |
| 12 | a int |
| 13 | } |
| 14 | |
| 15 | fn encode_struct[U](val U) { |
| 16 | $for field in U.fields { |
| 17 | _ = struct { |
| 18 | ...val.$(field.name) |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | fn main() { |
| 24 | aa := Aa{} |
| 25 | bb := Bb{} |
| 26 | aa_with_alias_type := AaWithAliasType{} |
| 27 | |
| 28 | encode_struct(aa) |
| 29 | encode_struct(aa_with_alias_type) |
| 30 | |
| 31 | encode_struct(bb) |
| 32 | } |
| 33 |