Skip to content

Commit 4f58a62

Browse files
authored
Add Hashable support for CG types (#6)
1 parent 1a1b9ad commit 4f58a62

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// CGGeometry+Hashable.swift
3+
// OpenCoreGraphics
4+
5+
#if !canImport(Darwin)
6+
// Foundation does not provide Hashable conformance for CG types yet.
7+
// See https://github.com/swiftlang/swift-corelibs-foundation/issues/5275
8+
extension CGPoint: Hashable {
9+
public func hash(into hasher: inout Hasher) {
10+
hasher.combine(x)
11+
hasher.combine(y)
12+
}
13+
}
14+
15+
extension CGSize: Hashable {
16+
public func hash(into hasher: inout Hasher) {
17+
hasher.combine(width)
18+
hasher.combine(height)
19+
}
20+
}
21+
22+
extension CGRect: Hashable {
23+
public func hash(into hasher: inout Hasher) {
24+
hasher.combine(origin)
25+
hasher.combine(size)
26+
}
27+
}
28+
#endif

0 commit comments

Comments
 (0)