From 1990e5d32dad0d94ce97a04584704f99092f10cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 31 Jan 2023 11:01:45 +0100 Subject: [PATCH] v0.0.74 --- langext/maps.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/langext/maps.go b/langext/maps.go index a0e5b25..6f06ed4 100644 --- a/langext/maps.go +++ b/langext/maps.go @@ -7,3 +7,11 @@ func MapKeyArr[T comparable, V any](v map[T]V) []T { } return result } + +func ArrToMap[T comparable, V any](a []V, keyfunc func(V) T) map[T]V { + result := make(map[T]V, len(a)) + for _, v := range a { + result[keyfunc(v)] = v + } + return result +}