mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 16:28:19 +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)
|
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