types/views: use slices.Contains{,Func}

Updates #8419

Change-Id: Ib1a9cb3fb425284b7e02684072a4e7a35975f35c
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/11946/head
Brad Fitzpatrick 7 months ago committed by Brad Fitzpatrick
parent 5db80cf2d8
commit c47f9303b0

@ -286,22 +286,12 @@ func (v Slice[T]) ContainsFunc(f func(T) bool) bool {
//
// As it runs in O(n) time, use with care.
func SliceContains[T comparable](v Slice[T], e T) bool {
for _, x := range v.ж {
if x == e {
return true
}
}
return false
return slices.Contains(v.ж, e)
}
// SliceContainsFunc reports whether f reports true for any element in v.
func SliceContainsFunc[T any](v Slice[T], f func(T) bool) bool {
for _, x := range v.ж {
if f(x) {
return true
}
}
return false
return slices.ContainsFunc(v.ж, f)
}
// SliceEqual is like the standard library's slices.Equal, but for two views.

Loading…
Cancel
Save