erigon-pulse/common/cmp/cmp.go
Alex Sharov d882a11c67
up linter version (#443)
* save

* save

* save

* save
2022-05-10 10:14:02 +07:00

31 lines
408 B
Go

package cmp
import (
"golang.org/x/exp/constraints"
)
// InRange - ensure val is in [min,max] range
func InRange[T constraints.Ordered](min, max, val T) T {
if min >= val {
return min
}
if max <= val {
return max
}
return val
}
func Min[T constraints.Ordered](a, b T) T {
if a <= b {
return a
}
return b
}
func Max[T constraints.Ordered](a, b T) T {
if a >= b {
return a
}
return b
}