Skip to content

Commit

Permalink
Map copy
Browse files Browse the repository at this point in the history
  • Loading branch information
teivah committed Dec 12, 2024
1 parent 712d9dd commit 4c530e2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ func InnerMapGet[K1 comparable, K2 comparable, X any](m map[K1]map[K2]X, k K1, c
}
return v
}

func MapCopy[K comparable, V any](m map[K]V) map[K]V {
res := make(map[K]V, len(m))
for k, v := range m {
res[k] = v
}
return res
}

0 comments on commit 4c530e2

Please sign in to comment.