mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[BasicContainers, DequeModule] Clean up Equatable/Hashable conformances
Make sure all types conditionally conform to Equatable/Hashable, even if their contents happen to be noncopyable.
This commit is contained in:
14 files changed
+95
-38
No files matched your search
@@ -13,16 +13,30 @@
|
||||
|
||||
#if compiler(>=6.2)
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueArray /*: Hashable */ where Element: Hashable /* & ~Copyable */ {
|
||||
@inlinable
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(self.count)
|
||||
let span = self.span
|
||||
for i in 0 ..< count {
|
||||
hasher.combine(span[unchecked: i])
|
||||
}
|
||||
}
|
||||
#if !COLLECTIONS_SINGLE_MODULE
|
||||
import InternalCollectionsUtilities
|
||||
#endif
|
||||
|
||||
#if compiler(>=6.4)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
extension UniqueArray: Hashable where Element: Hashable & ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueArray where Element: Hashable & ~Copyable {
|
||||
@inlinable
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
self._storage.hash(into: &hasher)
|
||||
}
|
||||
}
|
||||
#else
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueArray where Element: Hashable {
|
||||
@inlinable
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
self._storage.hash(into: &hasher)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user