1
0
mirror of https://github.com/go-task/task.git synced 2025-06-15 00:15:10 +02:00

feat: set and shopt directives (#929)

Co-authored-by: Andrey Nering <andrey@nering.com.br>
This commit is contained in:
Pete Davison
2023-01-14 13:41:56 -06:00
committed by GitHub
parent 4be1050234
commit 1c1be683ab
15 changed files with 308 additions and 19 deletions

View File

@ -0,0 +1,20 @@
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)
}