Documentation
¶
Index ¶
- func CopyPtr[T any](p *T) *T
- func Deref[T any](p *T, def T) T
- func DerefMap[S any, D any](p *S, f func(S) D, def D) D
- func DerefSlice[T any](p *[]T) []T
- func DerefSlicePtr[S any, D any](p *[]S, f func(S) D) []D
- func DerefSlicePtrE[S any, D any](p *[]S, f func(S) (D, error)) ([]D, error)
- func MapNullable[T, U any](n nullable.Nullable[T], f func(T) U) (*U, error)
- func MapNullableSlice[S, D any](n nullable.Nullable[[]S], f func(S) D) (*[]D, error)
- func MapNullableSliceV[S, D any](n nullable.Nullable[[]S], f func(S) D) ([]D, error)
- func MapNullableV[T, U any](n nullable.Nullable[T], f func(T) U, def U) (U, error)
- func MapPtr[S, D any](p *S, f func(S) D) *D
- func MapSlice[S any, D any](in []S, f func(S) D) []D
- func Ptr[T any](v T) *T
- func PtrIf[T comparable](v, zero T) *T
- func PtrIfNonZero[T ~int | ~int32 | ~int64](v T) *T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyPtr ¶
func CopyPtr[T any](p *T) *T
CopyPtr returns a new pointer with the same value, or nil if input is nil.
func Deref ¶
func Deref[T any](p *T, def T) T
Deref returns the value pointed to by p, or def if p is nil.
func DerefSlice ¶
func DerefSlice[T any](p *[]T) []T
DerefSlice returns a copy of the slice pointed to by p, or nil if p is nil.
func DerefSlicePtr ¶
DerefSlicePtr maps *[]S -> []D
func DerefSlicePtrE ¶
DerefSlicePtrE maps *[]S -> []D using f(S) (D, error). Returns nil, nil if p is nil.
func MapNullable ¶
MapNullable maps a nullable.Nullable[T] to *U using f. Returns nil when the field is unspecified OR explicitly null. Propagates Get() errors from the nullable package.
func MapNullableSlice ¶
MapNullableSlice maps a nullable.Nullable[[]S] to *[]D using f for elements. Returns nil when the field is unspecified OR explicitly null.
func MapNullableSliceV ¶ added in v0.0.30
MapNullableSliceV maps a nullable slice to a []D; returns nil (or empty) for unspecified/null.
func MapNullableV ¶ added in v0.0.30
MapNullableV maps a nullable field to a value using f; returns def for unspecified or null.
func MapPtr ¶
func MapPtr[S, D any](p *S, f func(S) D) *D
MapPtr applies f to *S and returns *D (nil-safe).
func PtrIf ¶ added in v0.0.30
func PtrIf[T comparable](v, zero T) *T
PtrIf returns a pointer to v if v != zero, otherwise nil. T must be comparable (e.g. not slices, maps, funcs). Examples: PtrIf("", "") -> nil PtrIf("x", "") -> *"x" PtrIf(int64(0), int64(0)) -> nil
func PtrIfNonZero ¶
PtrIfNonZero returns a pointer to v if v != 0, otherwise nil.
Types ¶
This section is empty.