Ref implemented
This commit is contained in:
parent
7988676059
commit
efc99a9658
10
to.go
10
to.go
@ -17,6 +17,16 @@ func Deref[T any](s []*T) []T {
|
||||
return out
|
||||
}
|
||||
|
||||
// Ref returns a slice containing pointers to all values of s.
|
||||
// The order in s is preserved.
|
||||
func Ref[T any](s []T) []*T {
|
||||
out := make([]*T, 0, len(s))
|
||||
Each(s, func(v T) {
|
||||
out = append(out, &v)
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
// ToList returns a list.List containing all values of s
|
||||
func ToList[T any](s []T) *list.List {
|
||||
l := list.New()
|
||||
|
Loading…
Reference in New Issue
Block a user