Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyOptions[S any](s *S, oo ...Option[S]) *S
- func Coalesce[T comparable](tt ...T) T
- func Copy[T any](tt []T) []T
- func Filter[T any](tt []T, match func(src T) bool) []T
- func Find[T any](tt []T, match func(src T) bool) *T
- func FindIndex[T any](tt []T, match func(src T) bool) int
- func Flat[T any](slices ...[]T) []T
- func FromAny[T any](src any) T
- func IdentityMiddleware[H any](h H) H
- func IndexOf[T comparable](expected T, tt []T) int
- func InsertIfNotExist[K comparable, V any](hm map[K]V, key K, value V)
- func IteratorCast[T comparable](i Iterator[any]) iteratorExtension[T]
- func Map[S, D any](ss []S, transformer Transformer[S, D]) []D
- func MatchEqual[T comparable](expected T) func(actual T) bool
- func PtrPtr[S, D any](src *S, transformer Transformer[S, D]) *D
- func PtrVal[T any](src *T) T
- func Reduce[T, R any](tt []T, reducer func(r R, t T) R) R
- func StringToRunes(src string) []rune
- func ToAny[T any](src T) any
- func ValPtr[T any](src T) *T
- type ChainIterator
- type InPlaceOption
- type Iterator
- type Middleware
- type MiddlewareStack
- type Option
- type OutOfPlaceOption
- type SliceIterator
- type Transformer
Constants ¶
Variables ¶
View Source
var ErrDuplicateEntry = errors.New("duplicate entry")
Functions ¶
func ApplyOptions ¶
func Coalesce ¶
func Coalesce[T comparable](tt ...T) T
Coalesce returns left-most non-zero value It's like cmp.Or
func IdentityMiddleware ¶ added in v0.9.0
func IdentityMiddleware[H any](h H) H
func IndexOf ¶
func IndexOf[T comparable](expected T, tt []T) int
func InsertIfNotExist ¶
func InsertIfNotExist[K comparable, V any](hm map[K]V, key K, value V)
func IteratorCast ¶ added in v0.11.0
func IteratorCast[T comparable](i Iterator[any]) iteratorExtension[T]
IteratorCast casts the elements of the iterator to the specified type. It is useful in cases where the type is lost in the transformation.
func Map ¶
func Map[S, D any](ss []S, transformer Transformer[S, D]) []D
func MatchEqual ¶
func MatchEqual[T comparable](expected T) func(actual T) bool
func PtrPtr ¶
func PtrPtr[S, D any](src *S, transformer Transformer[S, D]) *D
PtrPtr transforms pointer of type S to pointer of type D. If src is nil it returns nil
func PtrVal ¶
func PtrVal[T any](src *T) T
PtrVal dereferences a pointer of type T. If it's nil it returns the zero value of T
func StringToRunes ¶
Types ¶
type ChainIterator ¶ added in v0.11.0
type ChainIterator[T comparable] struct { // contains filtered or unexported fields }
func NewChainIterator ¶ added in v0.11.0
func NewChainIterator[T comparable](is ...Iterator[T]) *ChainIterator[T]
func (*ChainIterator[T]) Next ¶ added in v0.11.0
func (ci *ChainIterator[T]) Next() (T, bool)
type InPlaceOption ¶
type InPlaceOption[S any] func(s *S)
func (InPlaceOption[S]) Apply ¶
func (o InPlaceOption[S]) Apply(s *S) *S
type Iterator ¶ added in v0.11.0
type Iterator[T comparable] interface { Next() (T, bool) }
type Middleware ¶ added in v0.9.0
type Middleware[H any] func(next H) H
type MiddlewareStack ¶ added in v0.9.0
type MiddlewareStack[H any] Middleware[H]
func (MiddlewareStack[H]) Push ¶ added in v0.9.0
func (stk MiddlewareStack[H]) Push(mw Middleware[H]) MiddlewareStack[H]
type OutOfPlaceOption ¶
type OutOfPlaceOption[S any] func(s S) S
type SliceIterator ¶ added in v0.11.0
type SliceIterator[T comparable] struct { // contains filtered or unexported fields }
func NewSliceIterator ¶ added in v0.11.0
func NewSliceIterator[T comparable](s []T) *SliceIterator[T]
func (*SliceIterator[T]) Iter ¶ added in v0.11.0
func (si *SliceIterator[T]) Iter() iteratorExtension[T]
Iter returns an iterator extension. The extension provides additional functionality for the iterator. The extension is not thread-safe. The extension is not reusable. If you need to iterate again, call Clone.
func (*SliceIterator[T]) Next ¶ added in v0.11.0
func (si *SliceIterator[T]) Next() (T, bool)
type Transformer ¶
type Transformer[S, D any] func(src S) D
Source Files ¶
Click to show internal directories.
Click to hide internal directories.