Source file
test/typeparam/issue51840.go
1
2
3
4
5
6
7 package main
8
9 type Addr struct {
10 hi uint64
11 lo uint64
12 z *byte
13 }
14
15 func EqualMap[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {
16 for k, v1 := range m1 {
17 if v2, ok := m2[k]; !ok || v1 != v2 {
18 return false
19 }
20 }
21 return true
22 }
23
24 type Set[T comparable] map[T]struct{}
25
26 func NewSet[T comparable](items ...T) Set[T] {
27 return nil
28 }
29
30 func (s Set[T]) Equals(other Set[T]) bool {
31 return EqualMap(s, other)
32 }
33
34 func main() {
35 NewSet[Addr](Addr{0, 0, nil})
36 }
37
View as plain text