go.bigb.es/auxilia

v0.2.0
Doc Versions Source

Documentation

Package fn provides generic utility functions for zero values, tuple selectors, must-helpers, and partial application.

Functions

f func Curry1

src
func Curry1[V1 any](f func(V1), v1 V1) func()

Curry1 partially applies f with v1, returning a zero-argument closure.

f func FirstOf2

src
func FirstOf2[V1 any, V2 any](a V1, _ V2) V1

FirstOf2 returns the first of two arguments, discarding the second. It is useful for inlining multi-return calls when only the first value is needed.

f func FirstOf3

src
func FirstOf3[V1 any, V2 any, V3 any](a V1, _ V2, _ V3) V1

FirstOf3 returns the first of three arguments, discarding the rest.

f func GetType

src
func GetType[T any]() reflect.Type

GetType returns the reflect.Type of type T without requiring an instance.

f func IsZero

src
func IsZero[T comparable](inp T) bool

IsZero reports whether inp equals the zero value of its type.

f func Must

src
func Must(err error)

Must panics if err is non-nil. It is intended for wrapping calls that return only an error in contexts where failure is unexpected.

f func Must1

src
func Must1[V1 any](v1 V1, err error) V1

Must1 returns v1 or panics if err is non-nil. It is intended for wrapping calls of the form func() (T, error).

f func Must2

src
func Must2[V1 any, V2 any](v1 V1, v2 V2, err error) (V1, V2)

Must2 returns (v1, v2) or panics if err is non-nil. It is intended for wrapping calls of the form func() (T1, T2, error).

f func Must3

src
func Must3[V1 any, V2 any, V3 any](v1 V1, v2 V2, v3 V3, err error) (V1, V2, V3)

Must3 returns (v1, v2, v3) or panics if err is non-nil. It is intended for wrapping calls of the form func() (T1, T2, T3, error).

f func SecondOf2

src
func SecondOf2[V1 any, V2 any](_ V1, a V2) V2

SecondOf2 returns the second of two arguments, discarding the first.

f func SecondOf3

src
func SecondOf3[V1 any, V2 any, V3 any](_ V1, a V2, _ V3) V2

SecondOf3 returns the second of three arguments, discarding the rest.

f func ThirdOf3

src
func ThirdOf3[V1 any, V2 any, V3 any](_ V1, _ V2, a V3) V3

ThirdOf3 returns the third of three arguments, discarding the rest.

f func Zero

src
func Zero[T any]() T

Zero returns the zero value of type T.

Source Files