diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-07-26 14:03:31 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-08-01 16:02:02 +0200 |
| commit | 8a0c83d5d9f4cce90e814d9969850cd2e39d0592 (patch) | |
| tree | 5c37ff1529a8b26a58959e4ee234f2e285d03b1b | |
| parent | 68303e0872fa3370e31ec3e83a1d1f40c05caf37 (diff) | |
| download | mullvadvpn-8a0c83d5d9f4cce90e814d9969850cd2e39d0592.tar.xz mullvadvpn-8a0c83d5d9f4cce90e814d9969850cd2e39d0592.zip | |
OperationCompletion: add initializer that accepts Error?
| -rw-r--r-- | ios/MullvadVPN/Operations/OperationCompletion.swift | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ios/MullvadVPN/Operations/OperationCompletion.swift b/ios/MullvadVPN/Operations/OperationCompletion.swift index b8cf56a574..f75d17438d 100644 --- a/ios/MullvadVPN/Operations/OperationCompletion.swift +++ b/ios/MullvadVPN/Operations/OperationCompletion.swift @@ -57,6 +57,14 @@ enum OperationCompletion<Success, Failure: Error> { } } + init(error: Failure?) where Success == Void { + if let error = error { + self = .failure(error) + } else { + self = .success(()) + } + } + func map<NewSuccess>(_ block: (Success) -> NewSuccess) -> OperationCompletion<NewSuccess, Failure> { switch self { case .success(let value): |
