mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-24 00:22:57 +03:00
44d27207f8
* Column-only queries
27 lines
589 B
Go
27 lines
589 B
Go
// Package loz contains functionality supplemental to samber/lo.
|
|
// Ideally these functions would be merged into that package.
|
|
package loz
|
|
|
|
// All returns a new slice containing elems.
|
|
func All[T any](elems ...T) []T {
|
|
a := make([]T, len(elems))
|
|
copy(a, elems)
|
|
return a
|
|
}
|
|
|
|
// ToSliceType returns a new slice of type T, having performed
|
|
// type conversion on each element of in.
|
|
func ToSliceType[S, T any](in ...S) (out []T, ok bool) {
|
|
out = make([]T, len(in))
|
|
var a any
|
|
for i := range in {
|
|
a = in[i]
|
|
out[i], ok = a.(T)
|
|
if !ok {
|
|
return nil, false
|
|
}
|
|
}
|
|
|
|
return out, true
|
|
}
|