go项目脚手架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sorbet/pkg/misc/clamp.go

13 lines
151 B

package misc
import "cmp"
func Clamp[T cmp.Ordered](val, min, max T) T {
if val > max {
val = max
}
if val < min {
val = min
}
return val
}