-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #643 from apollographql/change/result-type
Switch to built-in `Result` type
- Loading branch information
Showing
6 changed files
with
42 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Foundation | ||
|
||
extension Result { | ||
|
||
/// Converts the result into an optional value. Returns the value for a `success` case and nil for a `failure` case. | ||
var value: Success? { | ||
switch self { | ||
case .success(let value): | ||
return value | ||
case .failure: | ||
return nil | ||
} | ||
} | ||
|
||
/// Converts the result into an optional error. Returns the error for a `failure` case and nil for a `success` case. | ||
/// Mostly useful for testing to make sure appropriate errors are received. | ||
var error: Failure? { | ||
switch self { | ||
case .success: | ||
return nil | ||
case .failure(let error): | ||
return error | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters