...
1
2
3
4
5
6
7
8 package p
9
10 import "fmt"
11
12 type F[A, B any] int
13
14 func G[A, B any](F[A, B]) {
15 }
16
17 func _() {
18
19 var x F [int]
20 G(x )
21 }
22
23
24
25
26 type RC[G any, RG any] interface {
27 ~[]RG
28 }
29
30 type RG[G any] struct{}
31
32 type RSC[G any] []*RG[G]
33
34 type M[Rc RC[G, RG], G any, RG any] struct {
35 Fn func(Rc)
36 }
37
38 type NFn[Rc RC[G, RG], G any, RG any] func(Rc)
39
40 func NC[Rc RC[G, RG], G any, RG any](nFn NFn[Rc, G, RG]) {
41 var empty Rc
42 nFn(empty)
43 }
44
45 func NSG[G any](c RSC[G]) {
46 fmt.Println(c)
47 }
48
49 func MMD[Rc RC [RG], RG any, G any]() M [Rc, RG] {
50
51 var nFn NFn [Rc, RG]
52
53 var empty Rc
54 switch any(empty).(type) {
55 case BC :
56
57 case RSC[G]:
58 nFn = NSG [G]
59 }
60
61 return M [Rc, RG]{
62 Fn: func(rc Rc) {
63 NC(nFn )
64 },
65 }
66
67 return M [Rc, RG]{}
68 }
69
View as plain text