Save retron function as non-throwing closure
As I understand it, rethrows
it essentially creates two functions from one declaration / definition, e.g .:
func f(_ c: () throws -> Void) rethrows { try c()}
// has the same effect as declaring two seperate functions, with the same name:
func g(_ c: () throws -> Void) throws { try c() }
func g(_ c: () -> Void) { c() }
If I have a rethrowing function, for example f
, is there a way to store it as a no-throw form closing in it? Hypothetically, like this:
let x: (() -> Void) -> Void = f
// invalid conversion from throwing function of type '(() throws -> Void) throws -> ()' to non-throwing function type '(() -> Void) -> Void'
x{ print("test") } // "try" not necessary, because x can't throw
+3
source to share