summaryrefslogtreecommitdiff
path: root/pkg/util/generic.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
commitbf2327276e6b3c8158a23362ca2fca5f46317e56 (patch)
tree7b45ba7c632a0932def8c9af9ecc98032bcfd2fa /pkg/util/generic.go
parentea17fd8e1e05c4fe0a38fa7d763f0e91bc28b967 (diff)
factor out a btrfsmisc pacage
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
+}