Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Result+init.swift
- //
- // Created by Yuji Yamamoto on 2019/06/23.
- // Copyright © 2019 Yuji Yamamoto. All rights reserved.
- //
- extension Swift.Result {
- init(_ closure: @autoclosure () throws -> Success) throws {
- do {
- self = .success(try closure())
- } catch {
- guard let typedError = error as? Failure else {
- throw error
- }
- self = .failure(typedError)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement