Skip to content

Commit

Permalink
CGPoint, CGSize, CGRect Conforms Hashable (#5134)
Browse files Browse the repository at this point in the history
  • Loading branch information
KYHyeon authored Nov 21, 2024
1 parent 731f3ae commit c28bf23
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit c28bf23

Please sign in to comment.