cosmos-sdk/testutil/list.go
Hieu Vu 1028e27f79
feat(x/epochs): upstream osmosis epoch module (#19697)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
2024-04-04 08:10:25 +00:00

15 lines
202 B
Go

package testutil
import (
"math/rand"
)
func RandSliceElem[E any](r *rand.Rand, elems []E) (E, bool) {
if len(elems) == 0 {
var e E
return e, false
}
return elems[r.Intn(len(elems))], true
}