Documentation
¶
Overview ¶
Package value provides value-first conditional selection. Use this for selecting a value with a fallback, not for executing branches of logic.
Index ¶
- Variables
- func FirstNonEmpty(vals ...string) string
- func FirstNonNil[T any](ptrs ...*T) (_ T)
- func FirstNonZero[T comparable](vals ...T) (_ T)
- func NonEmptyWith[R any](s string, fn func(string) R) option.Option[R]
- func NonNil[T any](t *T) option.Option[T]
- func NonNilWith[T any, R any](t *T, fn func(T) R) option.Option[R]
- func NonZero[T comparable](t T) option.Option[T]
- func NonZeroWith[T comparable, R any](t T, fn func(T) R) option.Option[R]
- type Cond
- type LazyCond
Constants ¶
This section is empty.
Variables ¶
var NonEmpty = option.NonEmpty
NonEmpty returns an ok option if s is not empty, or not-ok otherwise.
Functions ¶
func FirstNonEmpty ¶ added in v0.30.0
FirstNonEmpty returns the first non-empty string, or empty if all are empty. It is the string-specific variant of FirstNonZero.
func FirstNonNil ¶ added in v0.30.0
func FirstNonNil[T any](ptrs ...*T) (_ T)
FirstNonNil returns the dereferenced value of the first non-nil pointer, or zero if all are nil.
func FirstNonZero ¶ added in v0.30.0
func FirstNonZero[T comparable](vals ...T) (_ T)
FirstNonZero returns the first non-zero value, or zero if all are zero.
func NonEmptyWith ¶ added in v0.35.0
NonEmptyWith returns an ok option of fn(s) if s is not empty, or not-ok otherwise.
func NonNil ¶ added in v0.35.0
NonNil returns an ok option of *t if t is not nil, or not-ok otherwise.
func NonNilWith ¶ added in v0.35.0
NonNilWith returns an ok option of fn(*t) if t is not nil, or not-ok otherwise.
func NonZero ¶ added in v0.35.0
func NonZero[T comparable](t T) option.Option[T]
NonZero returns an ok option if t is not the zero value, or not-ok otherwise.
func NonZeroWith ¶ added in v0.35.0
func NonZeroWith[T comparable, R any](t T, fn func(T) R) option.Option[R]
NonZeroWith returns an ok option of fn(t) if t is not the zero value, or not-ok otherwise.
Types ¶
type Cond ¶
type Cond[T any] struct { // contains filtered or unexported fields }
Cond holds a value pending a condition check.