Last active
November 25, 2019 21:43
-
-
Save rustle/10e23530556d332b7d5ca2733a204a0b to your computer and use it in GitHub Desktop.
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
import Foundation | |
/* | |
Somewhere in Foundation | |
public protocol Foo { | |
... | |
public init<T>?(foo value: T) where T: Foo | |
... | |
} | |
*/ | |
extension Foo { | |
init<T>(foo value: T) throws where T: Foo { | |
guard let f = Self(foo: value) else { | |
throw FooError.noap | |
} | |
self = f | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment