Align BorrowingSequence etc with proposal

This updates the ContainersPreview module to use the same
API as the proposed BorrowingSequence protocol and its supporting
types. In particular, instead of using Span as the iterator for
itself and other contiguously-stored types, this introduces
SpanIterator.
This commit is contained in:
Nate Cook committed 2026-03-26 14:25:01 -05:00
1 parent b3d681b4e3
commit a2cf230400
4 files changed
+112 -64

No files matched your search

@@ -21,7 +21,7 @@ import ContainersPreview
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension RigidArray: BorrowingSequence where Element: ~Copyable {
public typealias BorrowingIterator = Span<Element>.BorrowingIterator
public typealias BorrowingIterator = SpanIterator<Element>
@inlinable
public var underestimatedCount: Int { count }
@@ -29,7 +29,7 @@ extension RigidArray: BorrowingSequence where Element: ~Copyable {
@_alwaysEmitIntoClient
@inline(__always)
public func makeBorrowingIterator() -> BorrowingIterator {
self.span.makeBorrowingIterator()
SpanIterator(self.span)
}
}
#endif