values

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2022 License: BSD-3-Clause Imports: 0 Imported by: 0

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 MapFunc

func MapFunc[F, T any](s []F, f func(F) T) []T

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL