14 lines
326 B
Go
14 lines
326 B
Go
package cursor
|
|
|
|
// DereferenceSlice takes a slice of pointers to T and returns a slice of T by
|
|
// dereferencing each pointer and discarding any nil pointers.
|
|
func DereferenceSlice[T any](list []*T) []T {
|
|
var result []T
|
|
for _, item := range list {
|
|
if item != nil {
|
|
result = append(result, *item)
|
|
}
|
|
}
|
|
return result
|
|
}
|