EnumerationSwift5.9.0
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
Citizens in Swift
Members
case failure(Failure)
A failure, storing a
Failure
value.case success(Success)
A success, storing a
Success
value.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.
Citizens in Swift
where Success:Sendable, Failure:Error
Conformances
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
Citizens in Swift
where Success:Hashable, Failure:Error, Failure:Hashable
Conformances
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.
Citizens in Swift
where Success:Equatable, Failure:Equatable, Failure:Error
Conformances
protocol Equatable
A type that can be compared for value equality.
Features
Citizens in Swift
where Failure == Error
Members
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.