From 0bf8de5d353b7b7957cb2231395f6818bc575b47 Mon Sep 17 00:00:00 2001 From: James Bean Date: Thu, 27 Jun 2019 03:28:36 -0400 Subject: [PATCH] Use hash(into:) for Rational: Hashable conformance (#34) * Use hash(into:) for Rational: Hashable conformance * Refine doc comment --- Package.resolved | 6 +++--- Sources/Math/Rational.swift | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index 26accce..8b9ff60 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,9 +14,9 @@ "package": "Structure", "repositoryURL": "https://github.com/dn-m/Structure", "state": { - "branch": "swift-5", - "revision": "8f67514cba950f60ee992a8d0996d4f11d9654b0", - "version": null + "branch": null, + "revision": "fc7d6a9dbaeb9c750988a6a142d5f67e395ddf69", + "version": "0.23.0" } } ] diff --git a/Sources/Math/Rational.swift b/Sources/Math/Rational.swift index f830e6b..1a43f7b 100644 --- a/Sources/Math/Rational.swift +++ b/Sources/Math/Rational.swift @@ -292,8 +292,11 @@ extension Rational { // MARK: - Hashable /// Hash value. - public var hashValue: Int { - return floatValue.hashValue + /// + /// - Note: `Rational` values are hashed by their `floatValue`. That is to say that `1/3` and `2/6` are hashed + /// equivalently. + public func hash(into hasher: inout Hasher) { + hasher.combine(floatValue) } }