github.com/searKing/golang/go@v1.2.117/exp/slices/contains.go (about) 1 // Copyright 2022 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package slices 6 7 import "slices" 8 9 // Contains reports whether v is present in s. 10 // Deprecated: Use slices.Contains instead since go1.21. 11 func Contains[E comparable](s []E, v E) bool { 12 return slices.Contains(s, v) 13 } 14 15 // ContainsFunc reports whether v satisfying f(s[i]) is present in s. 16 // Deprecated: Use slices.ContainsFunc instead since go1.21. 17 func ContainsFunc[E any](s []E, f func(E) bool) bool { 18 return slices.IndexFunc(s, f) >= 0 19 }