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 ChooseFunc[T any](cond bool, l, r func() T) T
- func ChooseLeft[L, R any](l L, _ R) L
- func ChooseRight[L, 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, R1, R2 any](l L, _ R1, _ R2) L
- func OnlyMiddle[L, M, R any](_ L, m M, _ R) M
- func OnlyRight[L1, L2, 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 ChooseFunc ¶ added in v0.3.0
ChooseFunc returns the result of the left function if cond is true, otherwise it returns the result of the right function. This function is useful when you need to conditionally choose between two functions.
func ChooseLeft ¶ added in v0.1.6
func ChooseLeft[L, R any](l L, _ R) L
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
func ChooseRight[L, R any](_ L, r R) R
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
func OnlyLeft[L, R1, R2 any](l L, _ R1, _ R2) L
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
func OnlyMiddle[L, M, R any](_ L, m M, _ R) M
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
func OnlyRight[L1, L2, R any](_ L1, _ L2, r R) R
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 result implements the unified result type for operations
|
Package result implements the unified result type for operations |
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 strings implements the functions, types, and interfaces for the module.
|
Package strings 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. |
reflection
Package reflection implements the functions, types, and interfaces for the module.
|
Package reflection 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. |