Skip to content

Commit 50bcb91

Browse files
committed
Simplify MapError implementation
1 parent 9614b29 commit 50bcb91

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

it/map.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,8 @@ func Map2[V, W, X, Y any](delegate func(func(V, W) bool), f func(V, W) (X, Y)) i
3131
func MapError[V, W any](delegate func(func(V) bool), f func(V) (W, error)) iter.Seq2[W, error] {
3232
return func(yield func(W, error) bool) {
3333
for value := range delegate {
34-
if result, err := f(value); err != nil {
35-
if !yield(result, err) {
36-
return
37-
}
38-
} else {
39-
if !yield(result, nil) {
40-
return
41-
}
34+
if !yield(f(value)) {
35+
return
4236
}
4337
}
4438
}

0 commit comments

Comments
 (0)