     import RxSwift
 #endif
 
+enum SequenceMaterializeResult<T> {
+    case completed(elements: [T])
+    case failed(elements: [T], error: Error)
+}
+
 extension BlockingObservable {
     /// Blocks current thread until sequence terminates.
     ///

    ///
    /// - returns: Last element in the sequence. If sequence is empty `nil` is returned.
    public func last() throws -> E? {
        return try convertToArray().last
    }
}


    /// - parameter predicate: A function to test each source element for a condition.
    /// - returns: Returns the only element of an sequence that satisfies the condition in the predicate, and reports an error if there is not exactly one element in the sequence.
    public func single(_ predicate: @escaping (E) throws -> Bool) throws -> E? {
        let results = convertToArray(max: 2, predicate: predicate)
        let elements = try elementsOrThrow(results)
        
        switch elements.count {
        case 0:
