summaryrefslogtreecommitdiff
path: root/pkg/btrfs/util.go
blob: 671d6fc2dbcc7446c240218a2fc409906e26aaac (plain)
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
package btrfs

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
}