Skip to content

CGPoint, CGSize, CGRect Conforms Hashable #5134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/Foundation/NSGeometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension CGPoint: Equatable {
}
}

extension CGPoint: NSSpecialValueCoding {
extension CGPoint: NSSpecialValueCoding, Hashable {
init(bytes: UnsafeRawPointer) {
self.x = bytes.load(as: CGFloat.self)
self.y = bytes.load(fromByteOffset: MemoryLayout<CGFloat>.stride, as: CGFloat.self)
Expand Down Expand Up @@ -75,7 +75,7 @@ extension CGPoint: NSSpecialValueCoding {
}
}

func hash(into hasher: inout Hasher) {
public func hash(into hasher: inout Hasher) {
hasher.combine(x)
hasher.combine(y)
}
Expand Down Expand Up @@ -132,7 +132,7 @@ extension CGSize: Equatable {
}
}

extension CGSize: NSSpecialValueCoding {
extension CGSize: NSSpecialValueCoding, Hashable {
init(bytes: UnsafeRawPointer) {
self.width = bytes.load(as: CGFloat.self)
self.height = bytes.load(fromByteOffset: MemoryLayout<CGFloat>.stride, as: CGFloat.self)
Expand Down Expand Up @@ -168,7 +168,7 @@ extension CGSize: NSSpecialValueCoding {
}
}

func hash(into hasher: inout Hasher) {
public func hash(into hasher: inout Hasher) {
hasher.combine(width)
hasher.combine(height)
}
Expand Down Expand Up @@ -451,7 +451,7 @@ public typealias NSRect = CGRect
public typealias NSRectPointer = UnsafeMutablePointer<NSRect>
public typealias NSRectArray = UnsafeMutablePointer<NSRect>

extension CGRect: NSSpecialValueCoding {
extension CGRect: NSSpecialValueCoding, Hashable {
init(bytes: UnsafeRawPointer) {
self.origin = CGPoint(
x: bytes.load(as: CGFloat.self),
Expand Down Expand Up @@ -491,7 +491,7 @@ extension CGRect: NSSpecialValueCoding {
}
}

func hash(into hasher: inout Hasher) {
public func hash(into hasher: inout Hasher) {
origin.hash(into: &hasher)
size.hash(into: &hasher)
}
Expand Down