Result
public enum Result
A type that represents either a wrapped value or an error, representing the possible return values of a throwing function.
-
Any error.
Declaration
Swift
public typealias Failure = Error -
The success value, stored as
Value.Declaration
Swift
case success(Success) -
The failure value, stored as any error.
Declaration
Swift
case failure(Failure)
-
Declaration
Swift
@inlinable public init(left error: Failure) -
Declaration
Swift
@inlinable public init(right value: Success) -
Declaration
Swift
@inlinable public init(catching body: () throws -> Success)
-
Declaration
Swift
@inlinable public func get() throws -> Success
-
Evaluates the
transformfor a success result, passing its unwrapped value as the parameter, to derive a new value.Use the
mapmethod with a closure that produces a new value.Declaration
Swift
public func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Task<NewSuccess>.Result -
Evaluates the
transformfor a success result, passing its unwrapped value as the parameter, to derive a new result.Use
flatMapwith a closure that itself returns a result.
-
Creates an instance storing a successful
value.Declaration
Swift
@inlinable public init(success value: @autoclosure() throws -> Success) -
Creates an instance storing an
errordescribing the failure.Declaration
Swift
@inlinable public init(failure error: Failure) -
Create an exclusive success/failure state derived from two optionals, in the style of Cocoa completion handlers.
Declaration
Swift
public init(value: Success?, error: Failure?)
-
Creates the success value.
Declaration
Swift
@inlinable public init()
View on GitHub
Install in Dash
Result Enumeration Reference