Skip to content

Commit c8cce63

Browse files
M0rtyMerrfreak4pc
authored andcommitted
Refactor elements & errors implementation
1 parent 714950d commit c8cce63

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Source/RxSwift/materialized+elements.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ extension ObservableType where Element: EventConvertible {
1616
- seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
1717
*/
1818
public func elements() -> Observable<Element.Element> {
19-
return filter { $0.event.element != nil }
20-
.map { $0.event.element! }
19+
return compactMap { $0.event.element }
2120
}
2221

2322
/**
2423
Returns an observable sequence containing only error elements from its input
2524
- seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
2625
*/
2726
public func errors() -> Observable<Swift.Error> {
28-
return filter { $0.event.error != nil }
29-
.map { $0.event.error! }
27+
return compactMap { $0.event.error }
3028
}
3129
}

0 commit comments

Comments
 (0)