utiliter

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorSeq2

func ErrorSeq2[K any](err error) iter.Seq2[K, error]

ErrorSeq2 creates a 2-value iterator that yields a single (zero-value, error) pair. Useful for returning early from a sequence pipeline with an error.

func Iter2ToIter2Err

func Iter2ToIter2Err[TOut any, TIn any](
	seq iter.Seq2[TIn, error],
) iter.Seq2[TOut, error]

Iter2ToIter2Err converts an iterator of (TIn, error) to (TOut, error), casting each item to TOut. If the error is non-nil, it is passed through with a zero-value TOut. Assumes TIn can be cast to TOut via empty interface.

func Iter2ToSlice

func Iter2ToSlice[TOut any, TIn iter.Seq2[K, V], K, V any](
	items TIn,
	cb func(k K, v V) TOut,
) []TOut

Iter2ToSlice converts a 2-value iterator into a slice using the provided mapping function. The iterator should yield (K, V) pairs, and cb maps each pair to an output element. Returns nil if the result is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL