Created
October 1, 2019 07:14
-
-
Save gwennguihal/b18ae6b2e5e0e36468920eb47e3ff985 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public struct IfLet<T: OptionalType>: Content { | |
| let data: T | |
| let builder: (T.Wrapped) -> Content | |
| public init(_ data: T, @ContentBuilder _ builder: @escaping (T.Wrapped) -> Content) { | |
| self.data = data | |
| self.builder = builder | |
| } | |
| public var contents: [Content]? { | |
| guard let value = data.value else { | |
| return nil | |
| } | |
| return [builder(value)] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment