helpers

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package helpers provides helper functions for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenPairs

func FlattenPairs[V any](pairs iter.Seq2[V, V]) iter.Seq[V]

FlattenPairs returns an iterator that yields values by flattening pairs.

func Limit

func Limit[V any](n int, values iter.Seq[V]) iter.Seq[V]

Limit returns an iterator sequence that yields at most n values.

func LimitPairs

func LimitPairs[V1, V2 any](n int, values iter.Seq2[V1, V2]) iter.Seq2[V1, V2]

LimitPairs returns an iterator sequence that yields at most n pairs.

func PairFold added in v0.4.0

func PairFold[V1, V2 any](pairs iter.Seq2[V1, V2]) iter.Seq[Pair[V1, V2]]

PairFold returns an iterator that transforms pairs to a sequence of [Pair]s.

func Swap

func Swap[V1, V2 any](pairs iter.Seq2[V1, V2]) iter.Seq2[V2, V1]

Swap returns an iterator that yields pairs with swapped values.

func ToPairs

func ToPairs[V, R1, R2 any, F ~func(V) (R1, R2)](values iter.Seq[V], f F) iter.Seq2[R1, R2]

ToPairs returns an iterator that yields pairs by applying the provided function to values.

Types

type Pair added in v0.4.0

type Pair[V1, V2 any] struct {
	V1 V1
	V2 V2
}

Pair is a pair of values.

func CollectPairs added in v0.4.0

func CollectPairs[V1, V2 any](pairs iter.Seq2[V1, V2]) []Pair[V1, V2]

CollectPairs returns a slice of pairs collected from the given iterator.

func NewPair added in v0.4.0

func NewPair[V1, V2 any](v1 V1, v2 V2) Pair[V1, V2]

NewPair returns a new pair of values.

Jump to

Keyboard shortcuts

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