| 1 | struct Test {} |
| 2 | |
| 3 | fn (t Test) test[T](val T) { |
| 4 | $for f in T.fields { |
| 5 | value := val.$(f.name) |
| 6 | $if f.is_option { |
| 7 | $if f.typ is $struct { |
| 8 | _ := 1 |
| 9 | t.test(value) |
| 10 | } $else $if f.typ is string { |
| 11 | _ := 2 |
| 12 | } $else $if f.typ is ?string { |
| 13 | _ := 3 |
| 14 | } $else { |
| 15 | _ := 4 |
| 16 | } |
| 17 | } $else { |
| 18 | $if f.typ is $struct { |
| 19 | t.test(value) |
| 20 | } $else $if f.typ is string { |
| 21 | _ := 5 |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | struct Bb { |
| 28 | a ?string |
| 29 | } |
| 30 | |
| 31 | struct Cc { |
| 32 | b Bb |
| 33 | } |
| 34 | |
| 35 | struct Aa[T] { |
| 36 | a T |
| 37 | } |
| 38 | |
| 39 | fn test_main() { |
| 40 | a := Aa[Cc]{} |
| 41 | t := Test{} |
| 42 | t.test(a) |
| 43 | assert true |
| 44 | } |
| 45 |