Skip to content

Commit

Permalink
fix: use generics for slice
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Sep 6, 2024
1 parent 7bcd4e4 commit 75c76d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions conv/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func String(val any) string {
}

// Strings returns the string slice representation of the values.
func Strings(vals ...any) []string {
func Strings[T any](vals ...T) []string {
strs := make([]string, len(vals))
for i, val := range vals {
strs[i] = String(val)
Expand Down Expand Up @@ -70,7 +70,7 @@ func Bool(val any) bool {
}

// Bools returns the boolean slice representation of the values.
func Bools(vals ...any) []bool {
func Bools[T any](vals ...T) []bool {
bools := make([]bool, len(vals))
for i, val := range vals {
bools[i] = Bool(val)
Expand Down Expand Up @@ -212,7 +212,7 @@ func Int(val any) int {
}

// Ints returns the integer slice representation of the values.
func Ints(vals ...any) []int {
func Ints[T any](vals ...T) []int {
ints := make([]int, len(vals))
for i, val := range vals {
ints[i] = Int(val)
Expand Down

0 comments on commit 75c76d9

Please sign in to comment.