diff --git a/Result/Result.swift b/Result/Result.swift index b08ea8e..f6234b3 100644 --- a/Result/Result.swift +++ b/Result/Result.swift @@ -120,29 +120,6 @@ public func materialize(_ f: @autoclosure () throws -> T) -> Result` instead") -public func materialize(_ f: () throws -> T) -> Result { - return materialize(try f()) -} - -@available(*, deprecated, message: "Use the overload which returns `Result` instead") -public func materialize(_ f: @autoclosure () throws -> T) -> Result { - do { - return .success(try f()) - } catch { -// This isn't great, but it lets us maintain compatibility until this deprecated -// method can be removed. -#if _runtime(_ObjC) - return .failure(error as NSError) -#else - // https://github.com/apple/swift-corelibs-foundation/blob/swift-3.0.2-RELEASE/Foundation/NSError.swift#L314 - let userInfo = _swift_Foundation_getErrorDefaultUserInfo(error) as? [String: Any] - let nsError = NSError(domain: error._domain, code: error._code, userInfo: userInfo) - return .failure(nsError) -#endif - } -} - // MARK: - Cocoa API conveniences #if !os(Linux) @@ -249,6 +226,7 @@ extension AnyError: LocalizedError { #endif // MARK: - migration support + extension Result { @available(*, unavailable, renamed: "success") public static func Success(_: T) -> Result { @@ -268,4 +246,16 @@ extension NSError { } } +@available(*, unavailable, message: "Use the overload which returns `Result` instead") +public func materialize(_ f: () throws -> T) -> Result { + fatalError() +} + +@available(*, unavailable, message: "Use the overload which returns `Result` instead") +public func materialize(_ f: @autoclosure () throws -> T) -> Result { + fatalError() +} + +// MARK: - + import Foundation diff --git a/Result/ResultProtocol.swift b/Result/ResultProtocol.swift index 165567a..77ed548 100644 --- a/Result/ResultProtocol.swift +++ b/Result/ResultProtocol.swift @@ -121,31 +121,6 @@ public extension ResultProtocol where Error: ErrorProtocolConvertible { // MARK: - Operators -infix operator &&& : LogicalConjunctionPrecedence - -/// Returns a Result with a tuple of `left` and `right` values if both are `Success`es, or re-wrapping the error of the earlier `Failure`. -@available(*, deprecated, renamed: "ResultProtocol.fanout(self:_:)") -public func &&& (left: L, right: @autoclosure () -> R) -> Result<(L.Value, R.Value), L.Error> - where L.Error == R.Error -{ - return left.fanout(right) -} - -precedencegroup ChainingPrecedence { - associativity: left - higherThan: TernaryPrecedence -} - -infix operator >>- : ChainingPrecedence - -/// Returns the result of applying `transform` to `Success`es’ values, or re-wrapping `Failure`’s errors. -/// -/// This is a synonym for `flatMap`. -@available(*, deprecated, renamed: "ResultProtocol.flatMap(self:_:)") -public func >>- (result: T, transform: (T.Value) -> Result) -> Result { - return result.flatMap(transform) -} - /// Returns `true` if `left` and `right` are both `Success`es and their values are equal, or if `left` and `right` are both `Failure`s and their errors are equal. public func == (left: T, right: T) -> Bool where T.Value: Equatable, T.Error: Equatable