Skip to content

Commit 7af65d9

Browse files
author
Dave Abrahams
authored
Merge pull request #7870 from stephentyrone/FloatingPoint-Hashable
FloatingPoint should imply Hashable. `Hashable` is related to `Equatable`, and `FloatingPoint` is `Equatable`, with enough additional constraints that `Hashable` conformance is practical. There's *almost* no excuse for any `Equatable` thing not to also be `Hashable`; the exception is when the underlying representation may be denormalized in some way that makes it impossible or expensive to normalize (e.g. `Set`). Floating point numbers have denormalized forms, so this comes down to the cost of normalization. Since we can't imagine a representation whose normalization is much more expensive than the subsequent hashing step, the conformance belongs.
2 parents 5a624eb + 0130407 commit 7af65d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/public/core/FloatingPoint.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
168168
/// "out of \(tempsFahrenheit.count) observations.")
169169
/// // Prints "Average: 74.84°F in 5 out of 7 observations."
170170
public protocol FloatingPoint: Comparable, Arithmetic,
171-
SignedNumber, Strideable {
171+
SignedNumber, Strideable, Hashable {
172172

173173
/// A type that represents any written exponent.
174174
associatedtype Exponent: SignedInteger

0 commit comments

Comments
 (0)