v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/slice/copy.go (about)

     1  package slice
     2  
     3  func Copy[T any](s []T) []T {
     4  	m := make([]T, len(s), cap(s))
     5  	copy(m[:cap(m)], s[:cap(s)])
     6  	return m
     7  }