blob: 3cc38c1cf4ed622df6c5de5ba1960046ae57d075 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package utils
func TypedSliceToInterfaceSlice[T any](s []T) []interface{} {
is := make([]interface{}, 0, len(s))
for _, t := range s {
is = append(is, t)
}
return is
}
func InterfaceSliceToTypedSlice[T any](s []interface{}) []T {
ts := make([]T, 0, len(s))
for _, t := range s {
ts = append(ts, t.(T))
}
return ts
}
|