Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inamiy/swift-intersection
Extensible records / intersection type in Swift.
https://github.com/inamiy/swift-intersection
Last synced: 29 days ago
JSON representation
Extensible records / intersection type in Swift.
- Host: GitHub
- URL: https://github.com/inamiy/swift-intersection
- Owner: inamiy
- License: mit
- Created: 2021-03-07T09:23:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-18T11:54:45.000Z (over 3 years ago)
- Last Synced: 2024-04-15T02:56:33.646Z (7 months ago)
- Language: Swift
- Size: 11.7 KB
- Stars: 21
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift-Intersection
Extensible records / intersection type in Swift.```swift
struct S1 {
var value1: Int
}struct S2 {
var value2: Bool
}let intersection = Intersection(S1(1), S2(true))
// Type of `intersection` works similar to `S1 & S2` (intersection type) in TypeScript), i.e.:
//
// struct S1_And_S2 {
// var value1: Int
// var value2: Bool
// }XCTAssertEqual(intersection.value1, 1)
XCTAssertEqual(intersection.value2, true)
```See also https://twitter.com/inamiy/status/1368468757702569986 .