-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconstraints.go
107 lines (92 loc) · 1.94 KB
/
constraints.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
//
// Copyright (C) 2022 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
// https://github.com/fogfish/golem
//
package pure
// String type constraints
//
// type MyType[T pure.String] ...
type String interface {
string
}
// AnyString type constraints
//
// type MyType[T pure.AnyString] ...
type AnyString interface {
~string
}
// Integer type constraints
//
// type MyType[T pure.Integer] ...
type Integer interface {
int | int8 | int16 | int32 | int64
}
// AnyInteger type constraints
//
// type MyType[T pure.AnyInteger] ...
type AnyInteger interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
}
// UInteger type constraints
//
// type MyType[T pure.UInteger] ...
type UInteger interface {
uint | uint8 | uint16 | uint32 | uint64
}
// AnyUInteger type constraints
//
// type MyType[T pure.AnyUInteger] ...
type AnyUInteger interface {
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}
// Float type constraints
//
// type MyType[T pure.Float] ...
type Float interface {
float32 | float64
}
// AnyFloat type constraints
//
// type MyType[T pure.AnyFloat] ...
type AnyFloat interface {
~float32 | ~float64
}
// Bool type constraints
//
// type MyType[T pure.Bool] ...
type Bool interface {
bool
}
// AnyBool type constraints
//
// type MyType[T pure.AnyBool] ...
type AnyBool interface {
~bool
}
// Number type constraints
//
// type MyType[T pure.Number] ...
type Number interface {
Integer | UInteger | Float
}
// AnyNumber type constraints
//
// type MyType[T pure.AnyNumber] ...
type AnyNumber interface {
AnyInteger | AnyUInteger | AnyFloat
}
// Orderable type constraints supports build-in compare operators
//
// type MyType[T pure.Orderable] ...
type Orderable interface {
Number | String
}
// AnyOrderable type constraints supports build-in compare operators
//
// type MyType[T pure.AnyOrderable] ...
type AnyOrderable interface {
AnyNumber | AnyString
}