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 @@ -303,7 +303,7 @@ extension RigidArray where Element: ~Copyable {
303303 /// This optimization may be removed in future versions; do not rely on it.
304304 ///
305305 /// - Parameter index: A valid index of the array. On return, `index` is
306- /// set to `limit` if
306+ /// set to the resulting position.
307307 /// - Parameter n: The distance to offset `index`.
308308 /// On return, `n` is set to zero if the operation succeeded without
309309 /// hitting the limit; otherwise, `n` reflects the number of steps that
Original file line number Diff line number Diff line change 1313
1414#if compiler(>=6.2)
1515
16+ // FIXME: Add this when/if SE-0499 gets implemented.
17+ //#if compiler(>=6.x)
18+ //@available(SwiftStdlib 5.0, *)
19+ //extension RigidArray: CustomStringConvertible where Element: ~Copyable {
20+ //}
21+ //#endif
22+
1623@available ( SwiftStdlib 5 . 0 , * )
17- extension RigidArray /*: CustomStringConvertible */ where Element: ~ Copyable {
24+ extension RigidArray where Element: ~ Copyable {
1825 public var description : String {
1926 /// FIXME: Print the item descriptions when available.
2027 " < \( count) items> "
2128 }
2229}
2330
31+ // FIXME: Add this when/if SE-0499 gets implemented.
32+ //#if compiler(>=6.5)
33+ //@available(SwiftStdlib 5.0, *)
34+ //extension RigidArray: CustomDebugStringConvertible where Element: ~Copyable {
35+ //}
36+ //#endif
37+
2438@available ( SwiftStdlib 5 . 0 , * )
25- extension RigidArray /*: CustomDebugStringConvertible */ where Element: ~ Copyable {
39+ extension RigidArray where Element: ~ Copyable {
2640 public var debugDescription : String {
2741 /// FIXME: Print the item descriptions when available.
2842 " < \( count) items> "
2943 }
3044}
3145
46+
3247#endif
Original file line number Diff line number Diff line change @@ -18,14 +18,25 @@ import InternalCollectionsUtilities
1818#endif
1919
2020@available ( SwiftStdlib 5 . 0 , * )
21- extension RigidArray /*: Equatable */ where Element: Equatable /* & ~Copyable */ {
21+ extension RigidArray where Element: ~ Copyable {
2222 public func isTriviallyIdentical( to other: borrowing Self ) -> Bool {
2323 self . _storage. _isIdentical ( to: other. _storage)
2424 && self . _count == other. _count
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 @@ -264,7 +264,7 @@ extension UniqueArray where Element: ~Copyable {
264264 /// This optimization may be removed in future versions; do not rely on it.
265265 ///
266266 /// - Parameter index: A valid index of the array. On return, `index` is
267- /// set to `limit` if
267+ /// set to the resulting position.
268268 /// - Parameter n: The distance to offset `index`.
269269 /// On return, `n` is set to zero if the operation succeeded without
270270 /// hitting the limit; otherwise, `n` reflects the number of steps that
Original file line number Diff line number Diff line change @@ -18,7 +18,26 @@ import InternalCollectionsUtilities
1818#endif
1919
2020@available ( SwiftStdlib 5 . 0 , * )
21- extension UniqueArray /*: Equatable */ where Element: Equatable /* & ~Copyable */ {
21+ extension UniqueArray where Element: ~ Copyable {
22+ public func isTriviallyIdentical( to other: borrowing Self ) -> Bool {
23+ self . _storage. isTriviallyIdentical ( to: other. _storage)
24+ }
25+ }
26+
27+ #if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
28+ @available ( SwiftStdlib 5 . 0 , * )
29+ extension UniqueArray : Equatable where Element: Equatable & ~ Copyable {
30+ @inlinable
31+ public static func == (
32+ left: borrowing Self ,
33+ right: borrowing Self
34+ ) -> Bool {
35+ left. span. _elementsEqual ( to: right. span)
36+ }
37+ }
38+ #else
39+ @available ( SwiftStdlib 5 . 0 , * )
40+ extension UniqueArray where Element: Equatable {
2241 @inlinable
2342 public static func == (
2443 left: borrowing Self ,
@@ -27,5 +46,6 @@ extension UniqueArray /*: Equatable */ where Element: Equatable /* & ~Copyable *
2746 left. span. _elementsEqual ( to: right. span)
2847 }
2948}
49+ #endif
3050
3151#endif
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ extension UniqueArray where Element: ~Copyable {
281281
282282@available ( SwiftStdlib 5 . 0 , * )
283283extension UniqueArray {
284- /// Copyies the elements of a fully initialized buffer pointer into this
284+ /// Copies the elements of a fully initialized buffer pointer into this
285285 /// array at the specified position.
286286 ///
287287 /// The new elements are inserted before the element currently at the
@@ -311,7 +311,7 @@ extension UniqueArray {
311311 unsafe _storage. insert ( copying: newElements, at: index)
312312 }
313313
314- /// Copyies the elements of a fully initialized buffer pointer into this
314+ /// Copies the elements of a fully initialized buffer pointer into this
315315 /// array at the specified position.
316316 ///
317317 /// The new elements are inserted before the element currently at the
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