1
0
mirror of https://github.com/go-task/task.git synced 2025-01-26 05:27:15 +02:00
task/internal/slicesext/slicesext.go

21 lines
336 B
Go
Raw Normal View History

package slicesext
import (
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)
func UniqueJoin[T constraints.Ordered](ss ...[]T) []T {
var length int
for _, s := range ss {
length += len(s)
}
r := make([]T, length)
var i int
for _, s := range ss {
i += copy(r[i:], s)
}
slices.Sort(r)
return slices.Compact(r)
}