Created
June 6, 2019 06:58
-
-
Save JasperH8g/42e49b65a7a3e63b25e3488febc5816f 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
struct IfLet<T, Out: View>: View { | |
let value: T? | |
let produce: (T) -> Out | |
init(_ value: T?, produce: @escaping (T) -> Out) { | |
self.value = value | |
self.produce = produce | |
} | |
var body: some View { | |
Group { | |
if value != nil { | |
produce(value!) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment