minireader/internal/pkg/utils/slices.go

14 lines
220 B
Go
Raw Normal View History

2023-10-25 14:49:11 +00:00
package utils
type Mapper[T, R any] func(T) R
func MapSlice[T, R any](input []T, mapper Mapper[T, R]) []R {
output := make([]R, len(input))
for i := range input {
output[i] = mapper(input[i])
}
return output
}