summaryrefslogtreecommitdiff
path: root/pkg/util/generic.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/util/generic.go')
-rw-r--r--pkg/util/generic.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/util/generic.go b/pkg/util/generic.go
new file mode 100644
index 0000000..79096ab
--- /dev/null
+++ b/pkg/util/generic.go
@@ -0,0 +1,28 @@
+package util
+
+import (
+ "golang.org/x/exp/constraints"
+)
+
+func InSlice[T comparable](needle T, haystack []T) bool {
+ for _, straw := range haystack {
+ if needle == straw {
+ return true
+ }
+ }
+ return false
+}
+
+func Max[T constraints.Ordered](a, b T) T {
+ if a > b {
+ return a
+ }
+ return b
+}
+
+func Min[T constraints.Ordered](a, b T) T {
+ if a < b {
+ return a
+ }
+ return b
+}