github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/utils/slice/slice.go (about) 1 package slice 2 3 func To[T, T2 any](from []T, f func(T) T2) []T2 { 4 to := make([]T2, len(from)) 5 for i, v := range from { 6 to[i] = f(v) 7 } 8 9 return to 10 }