1
2
3
4
5
6
7 package test
8
9
10
11
12
13
14
15
16
17
18
19 func Issue55357() {
20 type U struct {
21 A int
22 B string
23 C string
24 }
25 var q T55357[U]
26 q.Count()
27 q.List()
28
29 type M struct {
30 A int64
31 B uint32
32 C uint32
33 }
34 var q2 T55357[M]
35 q2.Count()
36 q2.List()
37 }
38
39 type T55357[T any] struct{}
40
41
42 func (q *T55357[T]) do(w, v bool, fn func(bk []byte, v T) error) error {
43 return nil
44 }
45
46 func (q *T55357[T]) Count() (n int, rerr error) {
47 err := q.do(false, false, func(kb []byte, _ T) error {
48 n++
49 return nil
50 })
51 return n, err
52 }
53
54 func (q *T55357[T]) List() (list []T, rerr error) {
55 var l []T
56 err := q.do(false, true, func(_ []byte, v T) error {
57 l = append(l, v)
58 return nil
59 })
60 if err != nil {
61 return nil, err
62 }
63 return l, nil
64 }
65
View as plain text