Skip to content

Instantly share code, notes, and snippets.

@inamiy
Created January 29, 2022 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inamiy/14426a88684b2f6e34a4e660233aa5a0 to your computer and use it in GitHub Desktop.
Save inamiy/14426a88684b2f6e34a4e660233aa5a0 to your computer and use it in GitHub Desktop.
@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