Documentation
¶
Index ¶
- func AllUntilError1[F ~func(A) error, A any](fs ...F) F
- func AllUntilError2[F ~func(A1, A2) error, A1, A2 any](fs ...F) F
- func Apply[T any](t T, f func(T)) T
- func Chain1[F ~func(A) A, A any](fs ...F) F
- func ChainReverse1[F ~func(A) A, A any](fs ...F) F
- func FoldBool[T any](success bool, onSuccess, onFailure T) T
- func FoldBoolFunc[T any](success bool, onSuccess, onFailure func() T) T
- func IsZero[T comparable](v T) bool
- func MapMap[M ~map[K]V, K comparable, V any, OK comparable, OV any](m M, mapper func(K, V) (OK, OV)) map[OK]OV
- func MapSlice[S ~[]T, T any, O any](slice S, mapper func(T) O) []O
- func MapSliceIndexed[S ~[]T, T any, O any](slice S, mapper func(int, T) O) []O
- func Must[T any](val T, err error) T
- func SliceDiff[S ~[]T, T comparable](before, after S) (additions, deletions S)
- func SliceDiffBy[S ~[]T, T any](before, after S, equal func(T, T) bool) (additions, deletions S)
- func SliceDistinct[S ~[]T, T cmp.Ordered](slice S) S
- func SliceDistinctBy[S ~[]T, T any](slice S, cmp func(T, T) int) S
- func Zero[T any]() (zero T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllUntilError1 ¶
AllUntilError1 returns a new function that calls all fs in order until one returns an error, and returns it, or if none fail, returns nil.
If fs... is empty, a function that does nothing and returns nil is returned.
func AllUntilError2 ¶
AllUntilError2 returns a new function that calls all fs in order until one returns an error, and returns it, or if none fail, returns nil.
If fs... is empty, a function that does nothing and returns nil is returned.
func Chain1 ¶
func Chain1[F ~func(A) A, A any](fs ...F) F
Chain1 returns a new function that when called, returns the result of calling fs... in the provided order.
If fs... is empty, then the identity function for F is returned, where the return value is equal to the argument.
func ChainReverse1 ¶
func ChainReverse1[F ~func(A) A, A any](fs ...F) F
ChainReverse1 returns a new function that when called, returns the result of calling fs... in the opposite of the provided order.
If fs... is empty, then the identity function for F is returned, where the return value is equal to the argument.
func FoldBoolFunc ¶
func IsZero ¶
func IsZero[T comparable](v T) bool
func MapMap ¶
func MapMap[M ~map[K]V, K comparable, V any, OK comparable, OV any](m M, mapper func(K, V) (OK, OV)) map[OK]OV
func MapSliceIndexed ¶
func SliceDiff ¶
func SliceDiff[S ~[]T, T comparable](before, after S) (additions, deletions S)
SliceDiff does the same thing as SliceDiffBy, but is a convenience for values that are directly comparable (or otherwise don't need custom comparison logic).
func SliceDiffBy ¶
SliceDiffBy returns two slices representing the additions and deletions done on before to get after. In other words, by adding everything in additions to before, and removing everything in deletions from before, the result would be equal to after.
Both before and after should be sorted in the same manner (method and order).
func SliceDistinct ¶
SliceDistinct is the same as SliceDistinctBy, but is more convenient for types that already satisfy cmp.Ordered.
func SliceDistinctBy ¶
SliceDistinctBy removes duplicate elements from slice as identified by cmp, and returns the resulting modified slice.
Note that in addition to contents, the order of elements in the resulting slice is note stable.
Types ¶
This section is empty.