Documentation
¶
Overview ¶
Package generic implements the functions, types, and interfaces for the module.
Index ¶
- func Choose[T any](cond bool, l, r T) T
- func ChooseLeft[L any, R any](l L, _ R) L
- func ChooseRight[L any, R any](_ L, r R) R
- func Must[T any](v T, err error) T
- func Must2[T any, U any](v T, u U, err error) (T, U)
- func MustLookup[T any](v T, ok bool) T
- func MustLookupOr[T any](def T, v T, ok bool) T
- func MustLookupOrNil[T any](v *T, ok bool) *T
- func MustLookupOrZero[T any](v T, ok bool) T
- func MustOr[T any](def T, v T, err error) T
- func MustOrNil[T any](v *T, err error) *T
- func MustOrZero[T any](v T, err error) T
- func OnlyLeft[L any, R1 any, R2 any](l L, _ R1, _ R2) L
- func OnlyMiddle[L any, M any, R any](_ L, m M, _ R) M
- func OnlyRight[L1 any, L2 any, R any](_ L1, _ L2, r R) R
- func OrNil[T any](_ T, err error) error
- func OrNil2[T any](_, _ T, err error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Choose ¶ added in v0.2.6
Choose returns the left value if cond is true, otherwise it returns the right value. This function is useful when you need to conditionally choose between two values.
func ChooseLeft ¶ added in v0.1.6
ChooseLeft returns the leftmost value, ignoring the right value. This function is useful when you need to prioritize the left value over the right.
func ChooseRight ¶ added in v0.1.6
ChooseRight returns the rightmost value, ignoring the left value. This function is useful when you need to prioritize the right value over the left.
func Must ¶
Must is a utility function that ensures a value is not nil and returns it. If the error is not nil, it panics with the error message.
func MustLookup ¶
MustLookup is a utility function that ensures a value is not nil and returns it. If the error is not nil, it panics with the error message.
func MustLookupOr ¶
MustLookupOr is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns the default value.
func MustLookupOrNil ¶
MustLookupOrNil is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns nil.
func MustLookupOrZero ¶
MustLookupOrZero is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns a zero value.
func MustOr ¶
MustOr is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns the default value.
func MustOrNil ¶
MustOrNil is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns nil.
func MustOrZero ¶
MustOrZero is a utility function that ensures a value is not nil and returns it. If the error is not nil, it returns a zero value.
func OnlyLeft ¶ added in v0.1.6
OnlyLeft returns the leftmost value, ignoring all other values. This function is useful when you need to extract the leftmost value from a tuple.
func OnlyMiddle ¶ added in v0.1.6
OnlyMiddle returns the middle value, ignoring all other values. This function is useful when you need to extract the middle value from a tuple.
func OnlyRight ¶ added in v0.1.6
OnlyRight returns the rightmost value, ignoring all other values. This function is useful when you need to extract the rightmost value from a tuple.
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
Package cmp implements the functions, types, and interfaces for the module.
|
Package cmp implements the functions, types, and interfaces for the module. |
Package maps implements the functions, types, and interfaces for the module.
|
Package maps implements the functions, types, and interfaces for the module. |
Package settings provides type-safe configuration management with default value handling.
|
Package settings provides type-safe configuration management with default value handling. |
Package slices implements the functions, types, and interfaces for the module.
|
Package slices implements the functions, types, and interfaces for the module. |
Package trans implements the functions, types, and interfaces for the module.
|
Package trans implements the functions, types, and interfaces for the module. |
Package types implements the functions, types, and interfaces for the module.
|
Package types implements the functions, types, and interfaces for the module. |