Documentation
¶
Index ¶
- func Coalesce[T any](ptrs ...*T) *T
- func Deref[T any](ptr *T, def T) T
- func DerefSlice[T any](ptrs []*T, def T) []T
- func Equal[T comparable](a, b *T) bool
- func IsNil[T any](ptr *T) bool
- func NonNilSlice[T any](ptrs []*T) []*T
- func To[T any](v T) *T
- func ToPointerSlice[T any](values []T) []*T
- func ToSlice[T any](ptr *T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Coalesce ¶
func Coalesce[T any](ptrs ...*T) *T
Coalesce returns the first non-nil pointer from the list. Returns nil if all pointers are nil.
func Deref ¶
func Deref[T any](ptr *T, def T) T
Deref dereferences ptr and returns the value it points to if not nil, or else returns def (the default value). This provides safe pointer dereferencing without nil checks.
func DerefSlice ¶
func DerefSlice[T any](ptrs []*T, def T) []T
DerefSlice dereferences all pointers in a slice, using def for nil pointers. Returns a new slice with dereferenced values.
func Equal ¶
func Equal[T comparable](a, b *T) bool
Equal compares two pointers for equality. Returns true if both are nil or both point to equal values. Returns false if one is nil and the other is not.
func NonNilSlice ¶
func NonNilSlice[T any](ptrs []*T) []*T
NonNilSlice returns a new slice containing only non-nil pointers from the input.
func To ¶
func To[T any](v T) *T
To returns a pointer to the given value. This is useful for creating pointers to literals or values in a single expression.
func ToPointerSlice ¶
func ToPointerSlice[T any](values []T) []*T
ToPointerSlice converts a slice of values to a slice of pointers. Each element in the result points to the corresponding element in the input.
Types ¶
This section is empty.