v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/slice/search.go (about)

     1  package slice
     2  
     3  func Search[T comparable](p []T, v T) int {
     4  	for i, x := range p {
     5  		if x == v {
     6  			return i
     7  		}
     8  	}
     9  	return -1
    10  }