新增泛型约束

This commit is contained in:
kercylan98 2023-05-09 12:09:25 +08:00
parent 00c4534574
commit b8e510454b
1 changed files with 21 additions and 0 deletions

21
utils/generic/type.go Normal file
View File

@ -0,0 +1,21 @@
package generic
type Ordered interface {
Integer | Float | ~string
}
type Integer interface {
Signed | Unsigned
}
type Signed interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Float interface {
~float32 | ~float64
}