-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
123 lines (106 loc) · 2.22 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package lo
// Entry defines a key/value pairs.
type Entry[K comparable, V any] struct {
Key K
Value V
}
// Tuple2 is a group of 2 elements (pair).
type Tuple2[A any, B any] struct {
A A
B B
}
// Unpack returns values contained in tuple.
func (t Tuple2[A, B]) Unpack() (A, B) {
return t.A, t.B
}
// Tuple3 is a group of 3 elements.
type Tuple3[A any, B any, C any] struct {
A A
B B
C C
}
// Unpack returns values contained in tuple.
func (t Tuple3[A, B, C]) Unpack() (A, B, C) {
return t.A, t.B, t.C
}
// Tuple4 is a group of 4 elements.
type Tuple4[A any, B any, C any, D any] struct {
A A
B B
C C
D D
}
// Unpack returns values contained in tuple.
func (t Tuple4[A, B, C, D]) Unpack() (A, B, C, D) {
return t.A, t.B, t.C, t.D
}
// Tuple5 is a group of 5 elements.
type Tuple5[A any, B any, C any, D any, E any] struct {
A A
B B
C C
D D
E E
}
// Unpack returns values contained in tuple.
func (t Tuple5[A, B, C, D, E]) Unpack() (A, B, C, D, E) {
return t.A, t.B, t.C, t.D, t.E
}
// Tuple6 is a group of 6 elements.
type Tuple6[A any, B any, C any, D any, E any, F any] struct {
A A
B B
C C
D D
E E
F F
}
// Unpack returns values contained in tuple.
func (t Tuple6[A, B, C, D, E, F]) Unpack() (A, B, C, D, E, F) {
return t.A, t.B, t.C, t.D, t.E, t.F
}
// Tuple7 is a group of 7 elements.
type Tuple7[A any, B any, C any, D any, E any, F any, G any] struct {
A A
B B
C C
D D
E E
F F
G G
}
// Unpack returns values contained in tuple.
func (t Tuple7[A, B, C, D, E, F, G]) Unpack() (A, B, C, D, E, F, G) {
return t.A, t.B, t.C, t.D, t.E, t.F, t.G
}
// Tuple8 is a group of 8 elements.
type Tuple8[A any, B any, C any, D any, E any, F any, G any, H any] struct {
A A
B B
C C
D D
E E
F F
G G
H H
}
// Unpack returns values contained in tuple.
func (t Tuple8[A, B, C, D, E, F, G, H]) Unpack() (A, B, C, D, E, F, G, H) {
return t.A, t.B, t.C, t.D, t.E, t.F, t.G, t.H
}
// Tuple9 is a group of 9 elements.
type Tuple9[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct {
A A
B B
C C
D D
E E
F F
G G
H H
I I
}
// Unpack returns values contained in tuple.
func (t Tuple9[A, B, C, D, E, F, G, H, I]) Unpack() (A, B, C, D, E, F, G, H, I) {
return t.A, t.B, t.C, t.D, t.E, t.F, t.G, t.H, t.I
}