Skip to content

Commit

Permalink
Delegate to slices.Concat
Browse files Browse the repository at this point in the history
  • Loading branch information
mokiat committed Mar 3, 2024
1 parent 2f14f92 commit 912c0f2
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions slice.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package gog

import "golang.org/x/exp/maps"
import (
"slices"

"golang.org/x/exp/maps"
)

// Map can be used to transform one slice into another by providing a
// function to do the mapping.
Expand Down Expand Up @@ -150,17 +154,10 @@ func DerefElements[T any](slice []*T) []T {
//
// This function always allocates a brand new slice with appropriate
// capacity and never mutates any of the passed slices.
func Concat[T any](slices ...[]T) []T {
capacity := 0
for _, slice := range slices {
capacity += len(slice)
}

result := make([]T, 0, capacity)
for _, slice := range slices {
result = append(result, slice...)
}
return result
//
// Deprecated: Use slices.Concat instead.
func Concat[T any](subSlices ...[]T) []T {
return slices.Concat(subSlices...)
}

// Merge takes a series of maps and merges them into a single map.
Expand Down

0 comments on commit 912c0f2

Please sign in to comment.