Last active
November 2, 2022 09:00
-
-
Save cjnevin/ffc89e6aad413c7d5f2224c7d2fb07e0 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
| @dynamicMemberLookup | |
| struct Assert<T> { | |
| let value: T | |
| subscript<Value>(dynamicMember keyPath: KeyPath<T, Value>) -> Assert<Value> { | |
| .init(value: value[keyPath: keyPath]) | |
| } | |
| } | |
| func assert<T>(_ root: T, _ closure: (Assert<T>) throws -> Void) rethrows { | |
| try closure(assert(root)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment