Make CopyOf generic
Test: util_test.go Change-Id: If8f2534ec454903eb967dc9ec0c8708096d1baff
This commit is contained in:
@@ -25,12 +25,12 @@ import (
|
||||
)
|
||||
|
||||
// CopyOf returns a new slice that has the same contents as s.
|
||||
func CopyOf(s []string) []string {
|
||||
func CopyOf[T any](s []T) []T {
|
||||
// If the input is nil, return nil and not an empty list
|
||||
if s == nil {
|
||||
return s
|
||||
}
|
||||
return append([]string{}, s...)
|
||||
return append([]T{}, s...)
|
||||
}
|
||||
|
||||
// Concat returns a new slice concatenated from the two input slices. It does not change the input
|
||||
|
Reference in New Issue
Block a user