This repository was archived by the owner on Aug 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-0
lines changed Expand file tree Collapse file tree 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public protocol Either {
4141
4242extension Either where Left == Error {
4343 /// Derive a success value by calling a failable function `body`.
44+ @_inlineable
4445 public init ( from body: ( ) throws -> Right ) {
4546 do {
4647 try self . init ( right: body ( ) )
@@ -50,6 +51,7 @@ extension Either where Left == Error {
5051 }
5152
5253 /// Returns the success value or throws the error.
54+ @_inlineable
5355 public func extract( ) throws -> Right {
5456 return try withValues ( ifLeft: { throw $0 } , ifRight: { $0 } )
5557 }
Original file line number Diff line number Diff line change 99extension TaskResult {
1010 /// Performs a coalescing operation, returning the result of unwrapping the
1111 /// success value of `result`, or `defaultValue` in case of an error.
12+ @_inlineable
1213 public static func ?? ( result: TaskResult < Value > , defaultValue: @autoclosure ( ) throws -> Value ) rethrows -> Value {
1314 switch result {
1415 case . success( let value) :
@@ -20,6 +21,7 @@ extension TaskResult {
2021
2122 /// Performs a coalescing operation, the wrapped success value `result`, or
2223 /// that of `defaultValue` in case of an error.
24+ @_inlineable
2325 public static func ?? ( result: TaskResult < Value > , defaultValue: @autoclosure ( ) throws -> TaskResult < Value > ) rethrows -> TaskResult < Value > {
2426 return try result. withValues ( ifLeft: { _ in try defaultValue ( ) } , ifRight: TaskResult . success)
2527 }
Original file line number Diff line number Diff line change @@ -19,11 +19,13 @@ public enum TaskResult<Value> {
1919
2020extension TaskResult {
2121 /// Creates an instance storing a successful `value`.
22+ @_inlineable
2223 public init ( success value: @autoclosure ( ) throws -> Value ) {
2324 self . init ( from: value)
2425 }
2526
2627 /// Creates an instance storing an `error` describing the failure.
28+ @_inlineable
2729 public init ( failure error: Error ) {
2830 self = . failure( error)
2931 }
@@ -50,6 +52,7 @@ private enum TaskResultInitializerError: Error {
5052extension TaskResult where Value == Void {
5153 /// Creates the success value.
5254 @available ( swift 4 )
55+ @_inlineable
5356 public init ( ) {
5457 self = . success( ( ) )
5558 }
@@ -58,14 +61,17 @@ extension TaskResult where Value == Void {
5861// MARK: - Compatibility with Protocol Extensions
5962
6063extension TaskResult : Either {
64+ @_inlineable
6165 public init ( left error: Error ) {
6266 self = . failure( error)
6367 }
6468
69+ @_inlineable
6570 public init ( right value: Value ) {
6671 self = . success( value)
6772 }
6873
74+ @_inlineable
6975 public func withValues< Return> ( ifLeft left: ( Error ) throws -> Return , ifRight right: ( Value ) throws -> Return ) rethrows -> Return {
7076 switch self {
7177 case let . success( value) :
You can’t perform that action at this time.
0 commit comments