diff --git a/pair.go b/pair.go index bb5cc573..dd858481 100644 --- a/pair.go +++ b/pair.go @@ -90,10 +90,10 @@ func RightOf[_ Pair[K, V], K, V any]() Operator[Pair[K, V], V] { ) } -// WithIndex maps each value emitted by the source Observable to a Pair -// containing two elements: the Key field stores the index of each value -// starting from init; the Value field stores the value. -func WithIndex[V any, K constraints.Integer](init K) Operator[V, Pair[K, V]] { +// Enumerate maps each value emitted by the source Observable to a Pair +// where the Key field stores the index of each value starting from init +// and the Value field stores each value. +func Enumerate[V any, K constraints.Integer](init K) Operator[V, Pair[K, V]] { return NewOperator( func(source Observable[V]) Observable[Pair[K, V]] { return func(c Context, o Observer[Pair[K, V]]) { diff --git a/pair_test.go b/pair_test.go index feda572b..72b8f8a9 100644 --- a/pair_test.go +++ b/pair_test.go @@ -108,7 +108,7 @@ func TestWithIndex(t *testing.T) { NewTestSuite[string](t).Case( rx.Pipe3( rx.Just("A", "B", "C"), - rx.WithIndex[string](1), + rx.Enumerate[string](1), rx.Reduce(make(map[int]string), add), ToString[map[int]string](), ), @@ -116,7 +116,7 @@ func TestWithIndex(t *testing.T) { ).Case( rx.Pipe3( rx.Throw[string](ErrTest), - rx.WithIndex[string](1), + rx.Enumerate[string](1), rx.Reduce(make(map[int]string), add), ToString[map[int]string](), ),