From 61e1b7350dec87a1d71ce78e24fdd134ca18d0fd Mon Sep 17 00:00:00 2001 From: Xander Deng Date: Fri, 10 Nov 2017 14:34:55 +0800 Subject: [PATCH] Make blocks throwable --- Sources/Then/Then.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Then/Then.swift b/Sources/Then/Then.swift index 2196638..2be8422 100644 --- a/Sources/Then/Then.swift +++ b/Sources/Then/Then.swift @@ -36,9 +36,9 @@ extension Then where Self: Any { /// $0.origin.x = 10 /// $0.size.width = 100 /// } - public func with(_ block: (inout Self) -> Void) -> Self { + public func with(_ block: (inout Self) throws -> Void) rethrows -> Self { var copy = self - block(©) + try block(©) return copy } @@ -49,8 +49,8 @@ extension Then where Self: Any { /// $0.set("devxoul@gmail.com", forKey: "email") /// $0.synchronize() /// } - public func `do`(_ block: (Self) -> Void) { - block(self) + public func `do`(_ block: (Self) throws -> Void) rethrows { + try block(self) } } @@ -64,8 +64,8 @@ extension Then where Self: AnyObject { /// $0.textColor = UIColor.blackColor() /// $0.text = "Hello, World!" /// } - public func then(_ block: (Self) -> Void) -> Self { - block(self) + public func then(_ block: (Self) throws -> Void) rethrows -> Self { + try block(self) return self }