Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Coalesce ¶
func Coalesce[T comparable](a ...T) T
Coalesce returns the first non-zero value in a, if any; otherwise it returns the zero value of T.
func Invert ¶
func Invert[K, V comparable](m map[K]V) map[V]K
func MaybeSet ¶
func MaybeSet[T comparable](v *T, a T)
MaybeSet is shorthand for:
v = Coalesce(v, a)
func MaybeZero ¶ added in v0.3.0
func MaybeZero[T comparable](v *T, zero T)
MaybeZero is shorthand for
v = ZeroIf(v, someValue)
func ZeroIf ¶ added in v0.3.0
func ZeroIf[T comparable](this, that T) T
ZeroIf returns the zero value of T if this is equal to that; otherwise it returns this. It never returns that.
Types ¶
type Collection ¶
type Collection[K comparable, V any] map[K][]V
func (*Collection[K, V]) Add ¶
func (c *Collection[K, V]) Add(key K, v V)
Click to show internal directories.
Click to hide internal directories.