diff --git a/langext/maps.go b/langext/maps.go index 6f06ed4..4a5cd11 100644 --- a/langext/maps.go +++ b/langext/maps.go @@ -15,3 +15,11 @@ func ArrToMap[T comparable, V any](a []V, keyfunc func(V) T) map[T]V { } return result } + +func CopyMap[K comparable, V any](a map[K]V) map[K]V { + result := make(map[K]V, len(a)) + for k, v := range a { + result[k] = v + } + return result +}