Skip to content

Instantly share code, notes, and snippets.

@AlexChekel1337
Created February 16, 2022 15:00
Show Gist options
  • Save AlexChekel1337/a3aa8a07d4ebeb526c382d3b48780177 to your computer and use it in GitHub Desktop.
Save AlexChekel1337/a3aa8a07d4ebeb526c382d3b48780177 to your computer and use it in GitHub Desktop.
Swift Result
extension Result where Success == Void {
static var success: Result<Success, Failure> {
return .success(())
}
}
// Example usage
func someFunctionThatReturnsResult() -> Result<Void, Error> {
// Allows to use just `.success` instead of `.success(())`
return .success
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment