Documentation
¶
Overview ¶
Package cmp implements the functions, types, and interfaces for the module.
Index ¶
- func Excludes[T comparable](src []T, ts ...T) []T
- func Has[T comparable](s []T, e T) bool
- func If[T any](condition bool, trueVal T, falseVal T) T
- func IfFunc[T any](condition bool, trueFn func() T, falseFn func() T) T
- func IfFuncWithError[T any](condition bool, trueFn func() (T, error), falseFn func() (T, error)) (T, error)
- func Includes[T comparable](src []T, ts ...T) []T
- func IsZero[T comparable](v T) bool
- func Or[T comparable](vals ...T) T
- func ZeroOr[T comparable](v T, rv T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Excludes ¶
func Excludes[T comparable](src []T, ts ...T) []T
Excludes returns the elements in src that are not in ts.
func If ¶ added in v0.2.5
If function takes a boolean condition and two values of any type T, and returns the first value if the condition is true, and the second value if the condition is false.
func IfFunc ¶ added in v0.2.5
IfFunc function takes a boolean condition, a function to execute if the condition is true, and a function to execute if the condition is false. It returns the result of the function that was executed.
func IfFuncWithError ¶ added in v0.2.5
func IfFuncWithError[T any](condition bool, trueFn func() (T, error), falseFn func() (T, error)) (T, error)
IfFuncWithError function takes a boolean condition, a function to execute if the condition is true, and a function to execute if the condition is false. It returns the result of the function that was executed.
func Includes ¶
func Includes[T comparable](src []T, ts ...T) []T
Includes returns the elements in src that are in ts.
func ZeroOr ¶
func ZeroOr[T comparable](v T, rv T) T
ZeroOr returns right value if v is the zero value.
Types ¶
This section is empty.