Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ func Count[T any](list []T, fn func(T) bool) int {
return ret
}

// Contains returns true if at least one element satisfying the predicate is found.
// Deprecated: use slices.ContainsFunc
func Contains[T any](list []T, fn func(T) bool) bool {
return slices.ContainsFunc(list, fn)
}

// ContainsAny returns true if any of the elements are present in the list.
func ContainsAny[T comparable](list []T, elms ...T) bool {
if len(list) == 0 || len(elms) == 0 {
Expand All @@ -121,12 +115,6 @@ func ContainsAny[T comparable](list []T, elms ...T) bool {
return false
}

// ContainsT returns true if any of the elements are present in the list.
// Deprecated: use ContainsAny
func ContainsT[T comparable](list []T, elms ...T) bool {
return ContainsAny(list, elms...)
}

// First returns the first element satisfying the predicate.
func First[T any](list []T, fn func(T) bool) (T, bool) {
idx := slices.IndexFunc(list, fn)
Expand Down
18 changes: 0 additions & 18 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,6 @@ func TestCount(t *testing.T) {
})
}

func TestContains(t *testing.T) {
f := func(n int) bool {
return n == 2
}

t.Run("empty", func(t *testing.T) {
require.False(t, slicex.Contains([]int{}, f))
})

t.Run("no matches", func(t *testing.T) {
require.False(t, slicex.Contains([]int{1, 3, 4}, f))
})

t.Run("matches", func(t *testing.T) {
require.True(t, slicex.Contains([]int{1, 3, 4, 2}, f))
})
}

func TestContainsAny(t *testing.T) {
t.Run("empty list", func(t *testing.T) {
require.False(t, slicex.ContainsAny([]int{}, 1))
Expand Down
Loading