mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 19:49:32 +02:00
Generic helper to concatenate arbitrary numbers of slices
This commit is contained in:
@@ -201,3 +201,16 @@ func Samefile(a, b any) bool {
|
||||
|
||||
return os.SameFile(sta, stb)
|
||||
}
|
||||
|
||||
func Concat[T any](slices ...[]T) []T {
|
||||
var total int
|
||||
for _, s := range slices {
|
||||
total += len(s)
|
||||
}
|
||||
result := make([]T, total)
|
||||
var i int
|
||||
for _, s := range slices {
|
||||
i += copy(result[i:], s)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user