Files
core/slices/equal.go
2023-07-06 10:27:56 +02:00

29 lines
654 B
Go

package slices
// EqualComparableElements returns whether two slices have the same elements.
func EqualComparableElements[T comparable](a, b []T) bool {
extraA, extraB := DiffComparable(a, b)
if len(extraA) == 0 && len(extraB) == 0 {
return true
}
return false
}
// Equaler defines a type that implements the Equal function.
type Equaler[T any] interface {
Equal(T) bool
}
// EqualEqualerElements returns whether two slices of Equaler have the same elements.
func EqualEqualerElements[T any, X Equaler[T]](a []T, b []X) bool {
extraA, extraB := DiffEqualer(a, b)
if len(extraA) == 0 && len(extraB) == 0 {
return true
}
return false
}