Documentation ¶
Index ¶
- func Cast[E any](v any) (E, error)
- func Const[E, F any](e E) func(F) E
- func DerefOr[E any](e *E, defaultValue E) E
- func DerefOrElse[E any](e *E, defaultFunc func() E) E
- func DerefOrZero[E any](e *E) E
- func Identity[E any](e E) E
- func MustCast[E any](v any) E
- func Pointer[E any](e E) *E
- func PointerOr[E any](e *E, defaultPtr *E) *E
- func PointerOrElse[E any](e *E, defaultFunc func() *E) *E
- func PointerOrNew[E any](e *E) *E
- func ReflectType[E any]() reflect.Type
- func TODO[V any](args ...any) V
- func Zero[E any]() E
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Const ¶
func Const[E, F any](e E) func(F) E
Const produces a function that takes an argument and returns the original argument, ignoring the passed-in value.
func DerefOr ¶
func DerefOr[E any](e *E, defaultValue E) E
DerefOr returns the value e points to if it's non-nil. Otherwise, it returns the defaultValue.
func DerefOrElse ¶
func DerefOrElse[E any](e *E, defaultFunc func() E) E
DerefOrElse returns the value e points to if it's non-nil. Otherwise, it returns the result of calling defaultFunc.
func DerefOrZero ¶
func DerefOrZero[E any](e *E) E
DerefOrZero returns the value e points to if it's non-nil. Otherwise, it returns the zero value for type E.
func Identity ¶
func Identity[E any](e E) E
Identity is a function that returns its given parameters.
func PointerOrElse ¶
func PointerOrElse[E any](e *E, defaultFunc func() *E) *E
func PointerOrNew ¶
func PointerOrNew[E any](e *E) *E
func ReflectType ¶
func TODO ¶
TODO is a function to create holes when stubbing out more complex mechanisms.
By default, it will panic with 'TODO: provide a value of type <type>' where <type> is the type of V. The panic message can be altered by passing in additional args that will be printed as 'TODO: <args separated by space>'
Types ¶
This section is empty.