mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
types/views: add AppendStrings util func
Updates tailscale/corp#19623 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
fd6ba43b97
commit
ed843e643f
@ -9,6 +9,7 @@
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
@ -277,6 +278,14 @@ func (v Slice[T]) ContainsFunc(f func(T) bool) bool {
|
||||
return slices.ContainsFunc(v.ж, f)
|
||||
}
|
||||
|
||||
// AppendStrings appends the string representation of each element in v to dst.
|
||||
func AppendStrings[T fmt.Stringer](dst []string, v Slice[T]) []string {
|
||||
for _, x := range v.ж {
|
||||
dst = append(dst, x.String())
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
// SliceContains reports whether v contains element e.
|
||||
//
|
||||
// As it runs in O(n) time, use with care.
|
||||
|
Loading…
Reference in New Issue
Block a user