...
1
2
3
4
5 package main
6
7 import "fmt"
8
9 func main() {
10 m := map[string]int{
11 "a": 6,
12 "b": 7,
13 }
14 fmt.Println(copyMap[map[string]int, string, int](m))
15 }
16
17 type Map[K comparable, V any] interface {
18 map[K] V
19 }
20
21 func copyMap[M Map[K, V], K comparable, V any](m M) M {
22 m1 := make(M)
23 for k, v := range m {
24 m1[k] = v
25 }
26 return m1
27 }
28
29
30
31 type A[X comparable] interface {
32 []X
33 }
34
35 func f[B A[X], X comparable]() B {
36 return nil
37 }
38
View as plain text