Skip to content

Commit

Permalink
Use hash(into:) for Rational: Hashable conformance (#34)
Browse files Browse the repository at this point in the history
* Use hash(into:) for Rational: Hashable conformance

* Refine doc comment
  • Loading branch information
jsbean authored and bwetherfield committed Jun 27, 2019
1 parent 47887e0 commit 0bf8de5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
7 changes: 5 additions & 2 deletions Sources/Math/Rational.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 0bf8de5

Please sign in to comment.