codekingpro/portable-devtools
114k
1// run2 3// Copyright 2021 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package main8 9//go:noinline10func CopyMap[M interface{ ~map[K]V }, K comparable, V any](m M) M {11 out := make(M, len(m))12 for k, v := range m {13 out[k] = v14 }15 return out16}17 18func main() {19 var m map[*string]int20 CopyMap(m)21}22 