mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-06 04:42:42 +00:00
types/views: add SliceEqual, like std slices.Equal
Updates tailscale/corp#6198 Change-Id: I38614a4552c9fa933036aa493c7cdb57c7ffe2d2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
b407fdef70
commit
e7d1538a2d
@@ -10,6 +10,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"go4.org/mem"
|
||||
)
|
||||
@@ -275,6 +276,11 @@ func SliceContains[T comparable](v Slice[T], e T) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// SliceEqual is like the standard library's slices.Equal, but for two views.
|
||||
func SliceEqual[T comparable](a, b Slice[T]) bool {
|
||||
return slices.Equal(a.ж, b.ж)
|
||||
}
|
||||
|
||||
// SliceEqualAnyOrder reports whether a and b contain the same elements, regardless of order.
|
||||
// The underlying slices for a and b can be nil.
|
||||
func SliceEqualAnyOrder[T comparable](a, b Slice[T]) bool {
|
||||
|
||||
Reference in New Issue
Block a user