| 1 | struct Maps { |
| 2 | a map[string]int |
| 3 | b map[string]bool |
| 4 | c map[string]f64 |
| 5 | } |
| 6 | |
| 7 | fn decode_struct[T](t T) []string { |
| 8 | mut decoded := []string{} |
| 9 | $for f in T.fields { |
| 10 | $if f is $map { |
| 11 | k, v := map_key_value(t.$(f.name)) |
| 12 | decoded << '${typeof(k).name} ${typeof(v).name}' |
| 13 | } |
| 14 | } |
| 15 | return decoded |
| 16 | } |
| 17 | |
| 18 | fn map_key_value[K, V](m map[K]V) (K, V) { |
| 19 | return K{}, V{} |
| 20 | } |
| 21 | |
| 22 | fn test_main() { |
| 23 | assert decode_struct(Maps{}) == ['string int', 'string bool', 'string f64'] |
| 24 | } |
| 25 |