summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-07-26 14:03:31 +0200
committerAndrej Mihajlov <and@mullvad.net>2022-08-01 16:02:02 +0200
commit8a0c83d5d9f4cce90e814d9969850cd2e39d0592 (patch)
tree5c37ff1529a8b26a58959e4ee234f2e285d03b1b
parent68303e0872fa3370e31ec3e83a1d1f40c05caf37 (diff)
downloadmullvadvpn-8a0c83d5d9f4cce90e814d9969850cd2e39d0592.tar.xz
mullvadvpn-8a0c83d5d9f4cce90e814d9969850cd2e39d0592.zip
OperationCompletion: add initializer that accepts Error?
-rw-r--r--ios/MullvadVPN/Operations/OperationCompletion.swift8
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):