mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
24 lines
376 B
Go
24 lines
376 B
Go
package taskfile
|
|
|
|
import "golang.org/x/exp/constraints"
|
|
|
|
func deepCopySlice[T any](orig []T) []T {
|
|
if orig == nil {
|
|
return nil
|
|
}
|
|
c := make([]T, len(orig))
|
|
copy(c, orig)
|
|
return c
|
|
}
|
|
|
|
func deepCopyMap[K constraints.Ordered, V any](orig map[K]V) map[K]V {
|
|
if orig == nil {
|
|
return nil
|
|
}
|
|
c := make(map[K]V, len(orig))
|
|
for k, v := range orig {
|
|
c[k] = v
|
|
}
|
|
return c
|
|
}
|