{{- /*gotype: go.mau.fi/mautrix-telegram/pkg/gotd/gen.structDef*/ -}} {{ define "struct_slice" }}{{ $f := . }} {{ template "slice" $f }} {{ range $field := sortableFields ($f.Fields) }} {{ template "slice_sort_by" concat ($f) ($field) }} {{ end }} {{ range $field := mapCollectableFields ($f.Fields) }} // FillMap fills constructors to given map. func (s {{ template "slice_name" $f }}) Fill{{ template "map_collector_name" $field }}Map(to map[{{ $field.Type }}]{{ $f.Name }} ) { for _, value := range s { to[value.Get{{ $field.Name }}()] = value } } // ToMap collects constructors to map. func (s {{ template "slice_name" $f }}) To{{ template "map_collector_name" $field }}Map() map[{{ $field.Type }}]{{ $f.Name }} { r := make(map[{{ $field.Type }}]{{ $f.Name }}, len(s)) s.Fill{{ template "map_collector_name" $field }}Map(r) return r } {{ end }} {{ end }}