Created
January 29, 2022 06:07
-
-
Save inamiy/14426a88684b2f6e34a4e660233aa5a0 to your computer and use it in GitHub Desktop.
Rethrowing protocol https://twitter.com/inamiy/status/1487305584684638208
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rethrows | |
protocol P { | |
func foo() throws | |
} | |
struct S1: P { | |
func foo() {} | |
} | |
struct S2: P { | |
func foo() throws {} | |
} | |
func testP<X: P>(_ x: X) rethrows { | |
try x.foo() | |
} | |
testP(S1()) // `try` is not required | |
try testP(S2()) // `try` is required |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment