Ref implemented

This commit is contained in:
Tordarus 2025-02-04 22:04:55 +01:00
parent 7988676059
commit efc99a9658

10
to.go
View File

@ -17,6 +17,16 @@ func Deref[T any](s []*T) []T {
return out 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 // ToList returns a list.List containing all values of s
func ToList[T any](s []T) *list.List { func ToList[T any](s []T) *list.List {
l := list.New() l := list.New()