Documentation
¶
Index ¶
- func Indirect[P *E, E any](p P) (E, bool)
- func IndirectOrZero[P *E, E any](p P) E
- func Pointer[E any](v E) *E
- func SwitchCases[K comparable, V any](key K, keys []K, values []V) (V, bool)
- func Ternary[T any](condition bool, exprIfTrue, exprIfFalse T) T
- func TernaryFunc[T any](condition bool, exprIfTrue, exprIfFalse func() T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndirectOrZero ¶
func IndirectOrZero[P *E, E any](p P) E
IndirectOrZero returns the value pointed to by p or zero value of E.
func Pointer ¶
func Pointer[E any](v E) *E
Pointer stores v in a new E value and returns a pointer to it.
func SwitchCases ¶
func SwitchCases[K comparable, V any](key K, keys []K, values []V) (V, bool)
func Ternary ¶
Ternary is akin to a ternary operator in Go, which based on the boolean `condition`, returns either `exprIfTrue` or `exprIfFalse`. It utilizes generics `T`, making it applicable for expressions of any type.
func TernaryFunc ¶
TernaryFunc is akin to a ternary operator in Go, which conditionally executes either `exprIfTrue` or `exprIfFalse` based on the value of `condition`, and returns the result of the executed function. It leverages Go's generics feature, making it applicable for any type `T`.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.