| 1 | type Any = string | int |
| 2 | |
| 3 | fn (m map[string]Any) to_toml() string { |
| 4 | mut t := '' |
| 5 | return t |
| 6 | } |
| 7 | |
| 8 | fn test_main() { |
| 9 | mut doc := map[string]Any{} |
| 10 | _ := encode(doc) |
| 11 | } |
| 12 | |
| 13 | fn encode[T](typ T) string { |
| 14 | $for method in T.methods { |
| 15 | $if method.name == 'to_toml' { |
| 16 | return typ.$method() |
| 17 | } |
| 18 | } |
| 19 | mp := encode_struct[T](typ) |
| 20 | return mp.to_toml() |
| 21 | } |
| 22 | |
| 23 | fn encode_struct[T](typ T) map[string]Any { |
| 24 | mut mp := map[string]Any{} |
| 25 | return mp |
| 26 | } |
| 27 |