File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 101101/// print("New tap detected at (\(nextTap.x), \(nextTap.y)).")
102102/// }
103103/// // Prints "New tap detected at (0, 1).")
104- public protocol Hashable : Equatable {
104+ public protocol Hashable : Equatable & ~ Copyable {
105105 /// The hash value.
106106 ///
107107 /// Hash values are not guaranteed to be equal across different executions of
@@ -135,9 +135,10 @@ public protocol Hashable: Equatable {
135135 func _rawHashValue( seed: Int ) -> Int
136136}
137137
138- extension Hashable {
138+ extension Hashable where Self : ~ Copyable {
139139 @inlinable
140140 @inline ( __always)
141+ @_preInverseGenerics
141142 public func _rawHashValue( seed: Int ) -> Int {
142143 var hasher = Hasher ( _seed: seed)
143144 hasher. combine ( self )
@@ -148,7 +149,8 @@ extension Hashable {
148149// Called by synthesized `hashValue` implementations.
149150@inlinable
150151@inline ( __always)
151- public func _hashValue< H: Hashable > ( for value: H ) -> Int {
152+ @_preInverseGenerics
153+ public func _hashValue< H: Hashable & ~ Copyable> ( for value: borrowing H ) -> Int {
152154 return value. _rawHashValue ( seed: 0 )
153155}
154156
Original file line number Diff line number Diff line change @@ -350,7 +350,8 @@ public struct Hasher {
350350 /// - Parameter value: A value to add to the hasher.
351351 @inlinable
352352 @inline ( __always)
353- public mutating func combine< H: Hashable > ( _ value: H ) {
353+ @_preInverseGenerics
354+ public mutating func combine< H: Hashable & ~ Copyable> ( _ value: borrowing H ) {
354355 value. hash ( into: & self )
355356 }
356357
Original file line number Diff line number Diff line change @@ -586,13 +586,15 @@ extension Optional: Equatable where Wrapped: Equatable & ~Copyable {
586586 }
587587}
588588
589- extension Optional : Hashable where Wrapped: Hashable {
589+ @_preInverseGenerics
590+ extension Optional : Hashable where Wrapped: Hashable & ~ Copyable {
590591 /// Hashes the essential components of this value by feeding them into the
591592 /// given hasher.
592593 ///
593594 /// - Parameter hasher: The hasher to use when combining the components
594595 /// of this instance.
595596 @inlinable
597+ @_preInverseGenerics
596598 public func hash( into hasher: inout Hasher ) {
597599 switch self {
598600 case . none:
You can’t perform that action at this time.
0 commit comments