fixed OfMap, OfSeq, OfSeq2

This commit is contained in:
milarin 2024-09-09 10:34:38 +02:00
parent d9d7a1586e
commit 29e60825bc

6
of.go
View File

@ -59,7 +59,7 @@ func OfFunc[T any](ctx context.Context, buffer int, f func() T) <-chan T {
func OfMap[K comparable, V, T any](m map[K]V, unmapper func(K, V) T) <-chan T {
out := make(chan T, len(m))
defer func() {
go func() {
defer close(out)
for k, v := range m {
out <- unmapper(k, v)
@ -73,7 +73,7 @@ func OfMap[K comparable, V, T any](m map[K]V, unmapper func(K, V) T) <-chan T {
func OfSeq[T any](seq iter.Seq[T]) <-chan T {
out := make(chan T, 10)
defer func() {
go func() {
defer close(out)
for v := range seq {
out <- v
@ -88,7 +88,7 @@ func OfSeq[T any](seq iter.Seq[T]) <-chan T {
func OfSeq2[K comparable, V, T any](seq iter.Seq2[K, V], unmapper func(K, V) T) <-chan T {
out := make(chan T, 10)
defer func() {
go func() {
defer close(out)
for key, value := range seq {
out <- unmapper(key, value)