FilterSuccess implemented
This commit is contained in:
parent
984aae2553
commit
b602502992
@ -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
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user