File tree Expand file tree Collapse file tree
InternalCollectionsUtilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,18 @@ extension RigidArray where Element: ~Copyable {
2525 }
2626}
2727
28-
28+ #if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
29+ @available ( SwiftStdlib 5 . 0 , * )
30+ extension RigidArray : Equatable where Element: Equatable & ~ Copyable {
31+ @inlinable
32+ public static func == (
33+ left: borrowing Self ,
34+ right: borrowing Self
35+ ) -> Bool {
36+ left. span. _elementsEqual ( to: right. span)
37+ }
38+ }
39+ #else
2940@available ( SwiftStdlib 5 . 0 , * )
3041extension RigidArray /*: Equatable */ where Element: Equatable /* & ~Copyable */ {
3142 @inlinable
@@ -36,5 +47,6 @@ extension RigidArray /*: Equatable */ where Element: Equatable /* & ~Copyable */
3647 left. span. _elementsEqual ( to: right. span)
3748 }
3849}
50+ #endif
3951
4052#endif
Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ extension UniqueArray where Element: ~Copyable {
2424 }
2525}
2626
27+ #if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
2728@available ( SwiftStdlib 5 . 0 , * )
28- extension UniqueArray /* : Equatable */ where Element: Equatable /* & ~Copyable */ {
29+ extension UniqueArray : Equatable where Element: Equatable & ~ Copyable {
2930 @inlinable
3031 public static func == (
3132 left: borrowing Self ,
@@ -34,5 +35,17 @@ extension UniqueArray /*: Equatable */ where Element: Equatable /* & ~Copyable *
3435 left. span. _elementsEqual ( to: right. span)
3536 }
3637}
38+ #else
39+ @available ( SwiftStdlib 5 . 0 , * )
40+ extension UniqueArray where Element: Equatable {
41+ @inlinable
42+ public static func == (
43+ left: borrowing Self ,
44+ right: borrowing Self
45+ ) -> Bool {
46+ left. span. _elementsEqual ( to: right. span)
47+ }
48+ }
49+ #endif
3750
3851#endif
Original file line number Diff line number Diff line change @@ -38,6 +38,26 @@ extension Span where Element: ~Copyable {
3838 }
3939}
4040
41+ #if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
42+ @available ( SwiftStdlib 5 . 0 , * )
43+ extension Span where Element: Equatable & ~ Copyable {
44+ @_alwaysEmitIntoClient
45+ package func _elementsEqual( to other: borrowing Self ) -> Bool {
46+ return self . withUnsafeBufferPointer { a in
47+ other. withUnsafeBufferPointer { b in
48+ guard a. count == b. count else { return false }
49+ guard a. baseAddress != b. baseAddress else { return true }
50+ var i = 0
51+ while i < self . count {
52+ guard a [ i] == b [ i] else { return false }
53+ i &+= 1
54+ }
55+ return true
56+ }
57+ }
58+ }
59+ }
60+ #else
4161@available ( SwiftStdlib 5 . 0 , * )
4262extension Span where Element: Equatable /* & ~Copyable */ {
4363 @_alwaysEmitIntoClient
@@ -56,6 +76,7 @@ extension Span where Element: Equatable /* & ~Copyable */ {
5676 }
5777 }
5878}
79+ #endif
5980
6081@available ( SwiftStdlib 5 . 0 , * )
6182extension Span where Element: Hashable /* & ~Copyable */ {
You can’t perform that action at this time.
0 commit comments