SHARE
TWEET

Untitled

a guest Jun 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  Result+init.swift
  3. //
  4. //  Created by Yuji Yamamoto on 2019/06/23.
  5. //  Copyright © 2019 Yuji Yamamoto. All rights reserved.
  6. //
  7.  
  8. extension Swift.Result {
  9.     init(_ closure: @autoclosure () throws -> Success) throws {
  10.         do {
  11.             self = .success(try closure())
  12.         } catch {
  13.             guard let typedError = error as? Failure else {
  14.                 throw error
  15.             }
  16.             self = .failure(typedError)
  17.         }
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top