You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
269 B

2 years ago
  1. package gentools
  2. func CopyMap[K comparable, V any](m map[K]V) map[K]V {
  3. m2 := make(map[K]V, len(m))
  4. for k, v := range m {
  5. m2[k] = v
  6. }
  7. return m2
  8. }
  9. func OneItemMap[K comparable, V any](key K, value V) map[K]V {
  10. m := make(map[K]V, 1)
  11. m[key] = value
  12. return m
  13. }