Documentation
¶
Index ¶
- func AsFilterIteratee[T any](f func(T) bool) func(T, int) bool
- func EmptyAsNil[T any](s []T) []T
- func ForEachUntilWithErr[T any](s []T, f func(T, int) (breaks bool, err error)) error
- func Last[T any](s []T, f func(T) bool) (*T, int, bool)
- func Map[T any, S any](s []T, f func(T) S) []S
- func MapWithErr[T any, S any](s []T, f func(T) (S, error)) ([]S, error)
- func SliceToPtrSlice[T any](s []T) []*T
- func UniqueGroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) (map[U]T, bool)
- type Diff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptyAsNil ¶
func EmptyAsNil[T any](s []T) []T
EmptyAsNil returns nil if the slice is empty otherwise the slice is returned. This is useful when in tests we are checking struct equality, as we don't need to care about the slice being zero length or nil.
func ForEachUntilWithErr ¶
func MapWithErr ¶
MapWithErr maps elements of a slice from T to M, returning a new slice and a joined error if there are any. If an error is returned from the mapping function, a nil array and the error is returned.
func SliceToPtrSlice ¶
func SliceToPtrSlice[T any](s []T) []*T
func UniqueGroupBy ¶
func UniqueGroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) (map[U]T, bool)
Types ¶
type Diff ¶
type Diff[T comparable, S ~[]T] struct { // contains filtered or unexported fields }
func NewDiff ¶
func NewDiff[T comparable, S ~[]T](base, new S) *Diff[T, S]
func (Diff[T, S]) HasChanged ¶
func (Diff[T, S]) InAdditions ¶
func (Diff[T, S]) InRemovals ¶
Click to show internal directories.
Click to hide internal directories.