diff --git a/result.go b/result.go index 87d4feb..5fc9054 100644 --- a/result.go +++ b/result.go @@ -48,3 +48,12 @@ func (r Result[T]) GetOrDefault(defaultValue T) T { func (r Result[T]) Get() (T, error) { return *r.value, r.err } + +func FilterSuccess[T any](source <-chan Result[T]) <-chan T { + succeeded := Filter(source, func(r Result[T]) bool { return r.Success() }) + + return MapSuccessive(succeeded, func(r Result[T]) T { + v, _ := r.Get() + return v + }) +}