[swift-users] [swift-evolution] Best way to handle escaping function that might throw
Anton Zhilin
antonyzhilin at gmail.com
Thu Jan 12 15:32:42 CST 2017
The best way to deal with such situations should be typed throws. Then
rethrows should be removed and replaced with generics in throws clause. E
== Never ⇔ function does not throw.
struct FStore<E> {
let f: () throws(E) -> Void
init(_ f: @escaping () throws(E) -> Void) { self.f = f }
func call() throws(E) { try f() }
}
let store = FStore<Never>({ print("Hello") })
store.call()
[Phase2]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170113/664fd2f6/attachment.html>
More information about the swift-users
mailing list