import toml struct Person { name string } fn decode[T](toml_str string) !T { res := T{} doc := toml.parse_text(toml_str)!.to_any() $for field in T.fields { val := doc.value(field.name) $if field.typ is string { res.$(field.name) = val.string() } } return res } p_str := 'name = "John"' decode[Person](p_str)!