Added min function to utils to get min between two
comparable types (how isn't it in the STL?)
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package utils
|
||||
|
||||
import "log"
|
||||
import (
|
||||
"log"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func Check(err error, msg string, args ...any) {
|
||||
if err != nil {
|
||||
@ -8,3 +12,10 @@ func Check(err error, msg string, args ...any) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Min[T constraints.Ordered](a, b T) T {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
Reference in New Issue
Block a user