try

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](it iter.Seq2[T, error], pred func(v T, err error) (bool, error)) (bool, error)

Any returns true if pred returns true for any element of the input sequence.

func And

func And[T any](preds ...func(v T, err error) (bool, error)) func(T, error) (bool, error)

And combines a list of predicates into a predicate that returns true if every predicate in the list returns true.

func Any

func Any[T any](it iter.Seq2[T, error], pred func(v T, err error) (bool, error)) (bool, error)

All returns true if pred returns true for every element of the input sequence.

func Concat

func Concat[T any](iters ...iter.Seq2[T, error]) iter.Seq2[T, error]

Concat returns an iterator that returns values from each iterator in sequence.

func ConcatMany

func ConcatMany[T any](iters iter.Seq[iter.Seq2[T, error]]) iter.Seq2[T, error]

ConcatMany returns an iterator that returns values from each iterator in sequence.

func FMap

func FMap[T, U any](it iter.Seq2[T, error], fn func(v T, err error) (U, bool, error)) iter.Seq2[U, error]

FMap returns a sequence of values computed by invoking fn on each element of the input sequence and returning only mapped values for with fn returns true.

func Filter

func Filter[T any](it iter.Seq2[T, error], fn func(v T, err error) (bool, error)) iter.Seq2[T, error]

Filter returns a sequence of values computed by invoking fn on each element of the input sequence and returning only those elements for with fn returns true.

func Map

func Map[T, U any](it iter.Seq2[T, error], fn func(v T, err error) (U, error)) iter.Seq2[U, error]

Map invokes fn on each value in the input sequence and returns the results.

func Must

func Must[T any](it iter.Seq2[T, error]) iter.Seq[T]

Must transforms a sequence of (T, error) pairs into a sequence of T values. If any element of the input sequence contains a non-nil error, the returned iterator will panic when that error is observed.

func NoError added in v2.0.1

func NoError[T any](_ T, err error) (bool, error)

NoError returns (true, nil) if err is nil.

func NoErrors added in v2.0.2

func NoErrors[T any](it iter.Seq2[T, error]) iter.Seq[T]

NoErrors transforms a sequence of (T, error) pairs into a sequence of T values, including only those values from pairs where the error is nil.

Equivalent to Must(Filter(it, NoError[T])).

func Not

func Not[T any](pred func(v T, err error) (bool, error)) func(T, error) (bool, error)

Not inverts the result of a predicate.

func OK

func OK[T any](it iter.Seq[T]) iter.Seq2[T, error]

OK transforms a sequence of values into a sequence of (T, nil) pairs.

func Or

func Or[T any](preds ...func(v T, err error) (bool, error)) func(T, error) (bool, error)

Or combines a list of predicates into a predicate that returns true if any predicate in the list returns true.

func PackAll

func PackAll[T any](it iter.Seq2[T, error]) iter.Seq[fx.Result[T]]

PackAll transforms a sequence of (T, error) pairs into a sequence of Result[T] values.

func Reduce

func Reduce[T, U any](it iter.Seq2[T, error], init U, fn func(acc U, v T, err error) (U, error)) (_ U, err error)

Reduce calls fn on each element of the input sequence, passing in the current value of the accumulator with each invocation and updating the accumulator to the result of fn after each invocation.

func Take

func Take[T any](it iter.Seq2[T, error], n int) iter.Seq2[T, error]

Take returns an iterator that takes at most n values from the input sequence.

func UnpackAll

func UnpackAll[T any](it iter.Seq[fx.Result[T]]) iter.Seq2[T, error]

UnpackAll transforms a sequence of Result[T] values into a sequence of (T, error) pairs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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