Result
A value that represents either a success or a failure, including an associated value in each case.
@frozen enum Result<Success, Failure> where Failure : Error
case failure(Failure)
A failure, storing a Failure
value.
case success(Success)
A success, storing a Success
value.
init(catching: () throws -> Success)
Creates a new result by evaluating a throwing closure, capturing the returned value as a success, or any thrown error as a failure.
func flatMap<NewSuccess>((Success) -> Result<NewSuccess, Failure>) -> Result<NewSuccess, Failure>
Returns a new result, mapping any success value using the given transformation and unwrapping the produced result.
func flatMapError<NewFailure>((Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure>
Returns a new result, mapping any failure value using the given transformation and unwrapping the produced result.
func get() throws -> Success
Returns the success value as a throwing expression.
func map<NewSuccess>((Success) -> NewSuccess) -> Result<NewSuccess, Failure>
Returns a new result, mapping any success value using the given transformation.
func mapError<NewFailure>((Failure) -> NewFailure) -> Result<Success, NewFailure>
Returns a new result, mapping any failure value using the given transformation.