From 6891eddf78778245cfa191b78b0bdded43b8161d Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 9 Oct 2025 02:53:30 +0800 Subject: [PATCH] Add Hashable support for CG types --- .../CGGeometry+Hashable.swift | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Sources/OpenCoreGraphics/CGGeometry+Hashable.swift diff --git a/Sources/OpenCoreGraphics/CGGeometry+Hashable.swift b/Sources/OpenCoreGraphics/CGGeometry+Hashable.swift new file mode 100644 index 0000000..fdf323c --- /dev/null +++ b/Sources/OpenCoreGraphics/CGGeometry+Hashable.swift @@ -0,0 +1,28 @@ +// +// CGGeometry+Hashable.swift +// OpenCoreGraphics + +#if !canImport(Darwin) +// Foundation does not provide Hashable conformance for CG types yet. +// See https://github.com/swiftlang/swift-corelibs-foundation/issues/5275 +extension CGPoint: Hashable { + public func hash(into hasher: inout Hasher) { + hasher.combine(x) + hasher.combine(y) + } +} + +extension CGSize: Hashable { + public func hash(into hasher: inout Hasher) { + hasher.combine(width) + hasher.combine(height) + } +} + +extension CGRect: Hashable { + public func hash(into hasher: inout Hasher) { + hasher.combine(origin) + hasher.combine(size) + } +} +#endif