Closed BooleanCat closed 1 year ago
Is your feature request related to a problem? Please describe.
It's not possible to chain Map iterators because of limitations with Go's type system (you cannot define new type parameters on methods). So this is not possible:
func (iter *BaseIter[T]) Transform[U any](func(T) U) *MapIter[T, U] { ... }
Describe the solution you'd like
I'd like a more limited version of the Map iterator where the return type is the same as the input type.
Provide code snippets to show how this new feature might be used.
The following should be possible and will allow chaining on simpler Map operations.
Map
func (iter *BaseIter[T]) Transform(func(T) T) *TransformIter[T] { ... }
evens := iter.Count().Transform(double).Take(5).Collect()
Does this incur a breaking change?
No.
Do you intend to build this feature yourself?
Maybe, be a good one for first time contributors to pick up.
TransformIter[T]
You may be able o short cut this by defining the Transform function as returning MapIter[T, T] and avoid writing a whole new iterator
Transform
MapIter[T, T]
Is your feature request related to a problem? Please describe.
It's not possible to chain Map iterators because of limitations with Go's type system (you cannot define new type parameters on methods). So this is not possible:
Describe the solution you'd like
I'd like a more limited version of the Map iterator where the return type is the same as the input type.
Provide code snippets to show how this new feature might be used.
The following should be possible and will allow chaining on simpler
Map
operations.Does this incur a breaking change?
No.
Do you intend to build this feature yourself?
Maybe, be a good one for first time contributors to pick up.
TransformIter[T]