aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-05-01 21:50:12 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-05-01 21:50:12 +0300
commit9fcf8e29214210612d545bed50d7f889800ac639 (patch)
tree3a99d2cd37fb8158d49abc1de6298758d205c9dd /utils
Initial
Diffstat (limited to 'utils')
-rw-r--r--utils/constraints.go11
-rw-r--r--utils/doc.go2
-rw-r--r--utils/ptr.go6
3 files changed, 19 insertions, 0 deletions
diff --git a/utils/constraints.go b/utils/constraints.go
new file mode 100644
index 0000000..c63ea63
--- /dev/null
+++ b/utils/constraints.go
@@ -0,0 +1,11 @@
+package utils
+
+// Scalar соответствует скалярам над которыми определены операции сравнения
+type Scalar interface {
+ ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
+}
+
+// Sortable соответствует типам над которыми определена операция Less
+type Sortable[T any] interface {
+ Less(T) bool
+}
diff --git a/utils/doc.go b/utils/doc.go
new file mode 100644
index 0000000..9087888
--- /dev/null
+++ b/utils/doc.go
@@ -0,0 +1,2 @@
+// Всякое разное
+package utils
diff --git a/utils/ptr.go b/utils/ptr.go
new file mode 100644
index 0000000..449f499
--- /dev/null
+++ b/utils/ptr.go
@@ -0,0 +1,6 @@
+package utils
+
+// Ptr получение указателя от произвольного значения, например, ToPtr(true) -> *bool(true)
+func Ptr[T any](t T) *T {
+ return &t
+}