generic

package
v0.0.0-...-66691d1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[E any](v any) (E, error)

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 MustCast

func MustCast[E any](v any) E

func Pointer

func Pointer[E any](e E) *E

Pointer returns a pointer for the given value.

func PointerOr

func PointerOr[E any](e *E, defaultPtr *E) *E

func PointerOrElse

func PointerOrElse[E any](e *E, defaultFunc func() *E) *E

func PointerOrNew

func PointerOrNew[E any](e *E) *E

func ReflectType

func ReflectType[E any]() reflect.Type

func TODO

func TODO[V any](args ...any) V

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>'

func Zero

func Zero[E any]() E

Zero returns the zero value for the given type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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