diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-05-02 15:05:04 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-05-14 15:00:56 +0200 |
| commit | 8d381a11ea8d3045e5e75d004b5151a6fb271428 (patch) | |
| tree | e5d1d49638a62aa110e374c558dab059cf2c1aa5 | |
| parent | c4cf8d870af5ba96dada7ef5514e28eb307b0312 (diff) | |
| download | mullvadvpn-8d381a11ea8d3045e5e75d004b5151a6fb271428.tar.xz mullvadvpn-8d381a11ea8d3045e5e75d004b5151a6fb271428.zip | |
Add Optional.unwrap
| -rw-r--r-- | ios/MullvadVPN/Optional+Unwrap.swift | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ios/MullvadVPN/Optional+Unwrap.swift b/ios/MullvadVPN/Optional+Unwrap.swift new file mode 100644 index 0000000000..80698c5e94 --- /dev/null +++ b/ios/MullvadVPN/Optional+Unwrap.swift @@ -0,0 +1,23 @@ + +// +// Optional+Unwrap.swift +// MullvadVPN +// +// Created by pronebird on 02/05/2019. +// Copyright © 2019 Amagicom AB. All rights reserved. +// + +import Foundation + +class NilUnwrapError: Error {} + +extension Optional { + func unwrap() throws -> Wrapped { + switch self { + case .some(let value): + return value + case .none: + throw NilUnwrapError() + } + } +} |
