Documentation
¶
Overview ¶
Package ptrx has helpers for optional values held as pointers, ported from taply's ptr package: defaults, fallbacks, comparison by value and mapping to proto optional fields.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal[T comparable](a, b *T) bool
Equal compares two optional values, nil meaning unset. Two nils are equal, a nil and a value are not, and two values are compared by content, not by address: this is what is meant by asking whether an optional field changed.
func NonZero ¶
func NonZero[T comparable](v T) *T
NonZero returns &v when v differs from its zero value, and nil otherwise. Intended for mapping domain primitives to proto `optional` fields so that empty-string or zero-int values serialize as absent rather than as "" / 0.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.