From 669eb09cea2608864e89339061330429b4b42e39 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 27 Jul 2026 13:31:20 -0700 Subject: [PATCH] Use `Iterable` from the Standard Library, replacing the local definition --- CMakeLists.txt | 1 + Package.swift | 1 + .../RigidArray/RigidArray+Append.swift | 18 +-- .../RigidArray/RigidArray+Container.swift | 22 ++-- .../RigidArray/RigidArray+Initializers.swift | 12 +- .../RigidArray/RigidArray+Replacements.swift | 6 +- .../RigidDictionary+Indices.swift | 19 ++- .../RigidSet/RigidSet+BorrowingSequence.swift | 26 ++-- .../RigidSet/RigidSet+Equatable.swift | 4 +- .../RigidSet/RigidSet+Hashable.swift | 4 +- .../RigidSet/RigidSet+Initializers.swift | 18 +-- .../RigidSet/RigidSet+Insertions.swift | 22 ++-- .../UniqueArray/UniqueArray+Append.swift | 24 ++-- .../UniqueArray/UniqueArray+Container.swift | 16 +-- .../UniqueArray+Initializers.swift | 12 +- .../UniqueSet+BorrowingSequence.swift | 13 +- .../UniqueSet/UniqueSet+Initializers.swift | 16 +-- .../UniqueSet/UniqueSet+Insertions.swift | 22 ++-- Sources/ContainersPreview/CMakeLists.txt | 5 - .../Conformances/Array+Iterable.swift | 11 +- .../Conformances/ClosedRange+Iterable.swift | 14 +-- .../Conformances/InlineArray+Iterable.swift | 31 ----- .../Conformances/InputSpan+Container.swift | 6 +- .../Conformances/InputSpan+Iterable.swift | 10 +- .../Conformances/MutableSpan+Container.swift | 9 +- .../Conformances/MutableSpan+Iterable.swift | 35 ------ .../Conformances/OutputSpan+Container.swift | 8 +- .../Conformances/OutputSpan+Iterable.swift | 31 ----- .../Conformances/Range+Iterable.swift | 14 +-- .../Conformances/Span+Container.swift | 50 ++++++-- .../Conformances/Span+Iterable.swift | 89 -------------- .../BorrowingIteratorProtocol+Copy.swift | 8 +- ...rowingIteratorProtocol+ElementsEqual.swift | 68 +++++----- .../BorrowingIteratorProtocol+Filter.swift | 32 ++--- .../BorrowingIteratorProtocol+Map.swift | 38 +++--- .../BorrowingIteratorProtocol+MapError.swift | 36 +++--- .../BorrowingIteratorProtocol+Reduce.swift | 18 +-- ...orrowingIteratorProtocol+SpanwiseZip.swift | 20 +-- .../Protocols/BorrowingIteratorProtocol.swift | 116 ++---------------- .../Container/Container+Filter.swift | 12 +- .../Protocols/Container/Container.swift | 15 +-- .../Container/ContainerIterator.swift | 17 ++- .../Container/RangeReplaceableContainer.swift | 28 ++--- .../Protocols/Iterable+Algorithms.swift | 62 +++++----- .../Protocols/Iterable+Utilities.swift | 12 +- .../Protocols/Iterable.swift | 64 ---------- .../RigidDeque/RigidDeque+Append.swift | 22 ++-- .../RigidDeque/RigidDeque+Container.swift | 12 +- .../RigidDeque/RigidDeque+Initializers.swift | 18 +-- .../RigidDeque/RigidDeque+Insertions.swift | 6 +- .../RigidDeque/RigidDeque+Prepend.swift | 38 +++--- .../RigidDeque/RigidDeque+Replacements.swift | 6 +- .../UniqueDeque/UniqueDeque+Append.swift | 22 ++-- .../UniqueDeque/UniqueDeque+Container.swift | 8 +- .../UniqueDeque+Initializers.swift | 18 +-- .../UniqueDeque/UniqueDeque+Insertions.swift | 6 +- .../UniqueDeque/UniqueDeque+Prepend.swift | 36 +++--- .../UniqueDeque+Replacements.swift | 6 +- .../RigidArrayTests.swift | 4 +- .../RigidDictionaryTests.swift | 12 +- .../BasicContainersTests/RigidSetTests.swift | 4 +- .../UniqueDictionaryTests.swift | 12 +- .../BorrowingSequenceTests.swift | 10 +- .../Assertions+Containers.swift | 54 ++++---- .../ConformanceCheckers/CheckContainer.swift | 34 ++--- .../MinimalTypes/StaccatoContainer.swift | 22 ++-- Xcode/Collections.xcodeproj/project.pbxproj | 20 --- Xcode/Shared.xcconfig | 1 + 68 files changed, 565 insertions(+), 921 deletions(-) delete mode 100644 Sources/ContainersPreview/Conformances/InlineArray+Iterable.swift delete mode 100644 Sources/ContainersPreview/Conformances/MutableSpan+Iterable.swift delete mode 100644 Sources/ContainersPreview/Conformances/OutputSpan+Iterable.swift delete mode 100644 Sources/ContainersPreview/Conformances/Span+Iterable.swift delete mode 100644 Sources/ContainersPreview/Protocols/Iterable.swift diff --git a/CMakeLists.txt b/CMakeLists.txt index d54544c7..6e32cd93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ set(collections_swift_flags "-enable-experimental-feature AddressableParameters" "-enable-experimental-feature AddressableTypes" "-enable-experimental-feature SuppressedAssociatedTypesWithDefaults" + "-enable-experimental-feature BorrowingSequence" ) foreach(flag ${collections_swift_flags}) add_compile_options("$<$:SHELL:${flag}>") diff --git a/Package.swift b/Package.swift index 70c83e3c..d9b2d967 100644 --- a/Package.swift +++ b/Package.swift @@ -116,6 +116,7 @@ let extraSettings: [SwiftSetting] = [ .enableExperimentalFeature("AddressableParameters"), .enableExperimentalFeature("AddressableTypes"), .enableExperimentalFeature("SuppressedAssociatedTypesWithDefaults"), // Requires Swift 6.4 + .enableExperimentalFeature("BorrowingSequence"), // 6.4 // Note: if you touch these, please make sure to also update the similar lists in // CMakeLists.txt and Xcode/Shared.xcconfig. ] diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Append.swift b/Sources/BasicContainers/RigidArray/RigidArray+Append.swift index f0df517b..7db3487f 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Append.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Append.swift @@ -256,11 +256,11 @@ extension RigidArray { @available(SwiftStdlib 6.4, *) @inlinable internal mutating func _append< - Source: Iterable_ & ~Copyable & ~Escapable + Source: Iterable & ~Copyable & ~Escapable >( copying newElements: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { let target = _freeSpace _count += try newElements._copyContents(intoPrefixOf: target) } @@ -280,11 +280,11 @@ extension RigidArray { @_alwaysEmitIntoClient @inline(__always) public mutating func append< - Source: Iterable_ & ~Copyable & ~Escapable + Source: Iterable & ~Copyable & ~Escapable >( copying newElements: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { try _append(copying: newElements) } #endif @@ -324,11 +324,11 @@ extension RigidArray { @_alwaysEmitIntoClient @inline(__always) public mutating func append< - Source: Iterable_ & Sequence + Source: Iterable & Sequence >( copying newElements: Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { try _append(copying: newElements) } #endif diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Container.swift b/Sources/BasicContainers/RigidArray/RigidArray+Container.swift index dc72b4df..eca09353 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Container.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Container.swift @@ -20,16 +20,13 @@ import ContainersPreview #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension RigidArray: Iterable_ where Element: ~Copyable { - public typealias BorrowingIterator_ = Span.BorrowingIterator_ +extension RigidArray: Iterable where Element: ~Copyable { + public typealias BorrowingIterator = Span.BorrowingIterator @_alwaysEmitIntoClient @inline(__always) - public func makeBorrowingIterator_() -> BorrowingIterator_ { - let span = self.span - let it = span.makeBorrowingIterator_() - // FIXME: `it` is borrowing `span`, not self - return _overrideLifetime(it, borrowing: self) + public func makeBorrowingIterator() -> BorrowingIterator { + self.span._makeBorrowingIterator(from: 0, to: count) } } #endif @@ -41,17 +38,14 @@ extension RigidArray: Container where Element: ~Copyable { @_lifetime(borrow self) public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { // FIXME: `makeBorrowingIterator` would be borrowing the temporary `span`, not self self.span._makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { - precondition( - iterator._span.isTriviallyIdentical(to: self.span), - "Invalid iterator instance") - return iterator._start + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + self.span.currentIndex(of: &iterator) } } @@ -73,7 +67,7 @@ extension RigidArray: RangeReplaceableContainer where Element: ~Copyable {} @available(SwiftStdlib 5.0, *) extension RigidArray where Element: ~Copyable { @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } /// A Boolean value indicating whether this array contains no elements. /// diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Initializers.swift b/Sources/BasicContainers/RigidArray/RigidArray+Initializers.swift index 9bd44efe..3aa6c53a 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Initializers.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Initializers.swift @@ -128,11 +128,11 @@ extension RigidArray /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init( + public init( capacity: Int, copying contents: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { self.init(capacity: capacity) try self.append(copying: contents) } @@ -151,11 +151,11 @@ extension RigidArray /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int, copying contents: Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { self.init(capacity: capacity) try self.append(copying: contents) } diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Replacements.swift b/Sources/BasicContainers/RigidArray/RigidArray+Replacements.swift index b193c14e..a0b52173 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Replacements.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Replacements.swift @@ -592,17 +592,17 @@ extension RigidArray { copyingContainer items: borrowing C, newCount: Int ) { - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() self.replace(removing: subrange, addingCount: newCount) { target in while !target.isFull { - let source = it.nextSpan_(maxCount: target.freeCapacity) + let source = it.nextSpan(maxCount: target.freeCapacity) precondition( !source.isEmpty, "Broken Container: count doesn't match contents") target._append(copying: source) } precondition( - it.nextSpan_().isEmpty, + it.nextSpan().isEmpty, "Broken Container: count doesn't match contents") } } diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift index de7e2951..f97c238c 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift @@ -43,14 +43,13 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable { } @available(SwiftStdlib 6.4, *) -extension RigidDictionary.Indices: Iterable_ +extension RigidDictionary.Indices: Iterable where Key: ~Copyable, Value: ~Copyable { public typealias Element = RigidDictionary.Index - public typealias Element_ = Element @frozen - public struct BorrowingIterator_: ~Escapable { + public struct BorrowingIterator: ~Escapable { public typealias Element = RigidDictionary.Index @usableFromInline @@ -70,24 +69,22 @@ where Key: ~Copyable, Value: ~Copyable } @inlinable - public var underestimatedCount_: Int { self._base.value.count } + public var underestimatedCount: Int { self._base.value.count } - @_lifetime(borrow self) // FIXME: Should be @_lifetime(copy self) - public func makeBorrowingIterator_() -> BorrowingIterator_ { + @_lifetime(borrow self) + public func makeBorrowingIterator() -> BorrowingIterator { let bit = self._base.value.makeBucketIterator() // FIXME: This override really should not be necessary. Check if the real `struct Borrow` fixes it. let override = _overrideLifetime(bit, copying: self) - return BorrowingIterator_(_it: override) + return BorrowingIterator(_it: override) } } @available(SwiftStdlib 6.4, *) -extension RigidDictionary.Indices.BorrowingIterator_: BorrowingIteratorProtocol_ +extension RigidDictionary.Indices.BorrowingIterator: BorrowingIteratorProtocol where Key: ~Copyable, Value: ~Copyable { - public typealias Element_ = Element - @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { guard _it.advanceToOccupied() else { return .init() } _current[0] = Element(_bucket: _it.currentBucket) _it.advanceToNextBit() diff --git a/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift b/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift index a62eb9bb..22c5263f 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift @@ -18,14 +18,12 @@ import ContainersPreview #if compiler(>=6.4) && UnstableHashedContainers && UnstableContainersPreview @available(SwiftStdlib 5.0, *) -extension RigidSet: Iterable_ where Element: ~Copyable { - public typealias Element_ = Element - +extension RigidSet: Iterable where Element: ~Copyable { @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @inlinable - public func _customContainsEquatableElement_( + public func _customContainsEquatableElement( _ element: borrowing Element ) -> Bool? { self.contains(element) @@ -33,20 +31,18 @@ extension RigidSet: Iterable_ where Element: ~Copyable { @inlinable @_lifetime(borrow self) - public borrowing func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(_set: self) + public borrowing func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(_set: self) } @frozen - public struct BorrowingIterator_: - BorrowingIteratorProtocol_, + public struct BorrowingIterator: + BorrowingIteratorProtocol, ~Copyable, ~Escapable { - public typealias Element_ = Element - @_alwaysEmitIntoClient - internal var _baseAddress: UnsafePointer? + internal var _baseAddress: UnsafePointer? @_alwaysEmitIntoClient internal var _bucketIterator: _HTable.BucketIterator @@ -54,7 +50,7 @@ extension RigidSet: Iterable_ where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(borrow _set) internal init( - _set: borrowing RigidSet + _set: borrowing RigidSet ) { self._baseAddress = .init(_set._members) self._bucketIterator = _set._table.makeBucketIterator() @@ -62,7 +58,7 @@ extension RigidSet: Iterable_ where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(copy self) - internal func _span(over buckets: Range<_Bucket>) -> Span { + internal func _span(over buckets: Range<_Bucket>) -> Span { let items = UnsafeBufferPointer( start: _baseAddress.unsafelyUnwrapped + buckets.lowerBound.offset, count: buckets.upperBound.offset - buckets.lowerBound.offset) @@ -71,7 +67,7 @@ extension RigidSet: Iterable_ where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int = .max) -> Span { precondition(maxCount > 0, "maxCount must be positive") guard let next = _bucketIterator.nextOccupiedRegion(maxCount: maxCount) diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift b/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift index 5deb0e5a..3a3ce7c5 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift @@ -40,9 +40,9 @@ extension RigidSet where Element: ~Copyable { guard left.count == right.count else { return false } #if UnstableContainersPreview - var lit = left.makeBorrowingIterator_() + var lit = left.makeBorrowingIterator() while true { - let l = lit.nextSpan_() + let l = lit.nextSpan(maxCount: .max) if l.isEmpty { break } var i = 0 while i < l.count { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift b/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift index 058032a7..de92a70b 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift @@ -37,9 +37,9 @@ extension RigidSet where Element: ~Copyable { public func _rawHashValue(seed: Int) -> Int { #if UnstableContainersPreview var hash = 0 - var it = self.makeBorrowingIterator_() + var it = self.makeBorrowingIterator() while true { - let next = it.nextSpan_() + let next = it.nextSpan() var i = 0 while i < next.count { hash ^= next[unchecked: i]._rawHashValue(seed: seed) diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift b/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift index 4bb4f0dd..9c9b48fe 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift @@ -86,12 +86,12 @@ extension RigidSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public init< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( capacity: Int, copying contents: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity) try self._insert(copying: contents) } @@ -122,12 +122,12 @@ extension RigidSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public init< - S: Iterable_ & Sequence + S: Iterable & Sequence >( capacity: Int, copying contents: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity) try self._insert(copying: contents) } @@ -136,12 +136,12 @@ extension RigidSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public init< - S: Iterable_ & Collection + S: Iterable & Collection >( capacity: Int? = nil, copying contents: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity ?? contents.count) try self._insert(copying: contents) } diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift b/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift index 7bee7ad0..c68ba645 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift @@ -239,14 +239,14 @@ extension RigidSet /* where Element: Copyable */ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient package mutating func _insert< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() + ) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() guard !span.isEmpty else { break } self.insert(copying: span) } @@ -258,11 +258,11 @@ extension RigidSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public mutating func insert< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try _insert(copying: items) } #endif @@ -281,11 +281,11 @@ extension RigidSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public mutating func insert< - S: Iterable_ & Sequence + S: Iterable & Sequence >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try _insert(copying: items) } #endif diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift index 56027fe9..defdf685 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+Append.swift @@ -261,15 +261,15 @@ extension UniqueArray { @available(SwiftStdlib 6.4, *) @inlinable internal mutating func _append< - Source: Iterable_ & ~Copyable & ~Escapable + Source: Iterable & ~Copyable & ~Escapable >( copying newElements: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { - _ensureFreeCapacity(newElements.underestimatedCount_) - var it = newElements.makeBorrowingIterator_() + ) throws(Source.Failure) + where Source.Element == Element { + _ensureFreeCapacity(newElements.underestimatedCount) + var it = newElements.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() if span.isEmpty { break } _ensureFreeCapacity(span.count) _storage.append(copying: span) @@ -296,11 +296,11 @@ extension UniqueArray { @_alwaysEmitIntoClient @inline(__always) public mutating func append< - Source: Iterable_ & ~Copyable & ~Escapable + Source: Iterable & ~Copyable & ~Escapable >( copying newElements: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { try self._append(copying: newElements) } @@ -352,11 +352,11 @@ extension UniqueArray { @_alwaysEmitIntoClient @inline(__always) public mutating func append< - Source: Iterable_ & Sequence + Source: Iterable & Sequence >( copying newElements: Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { try self._append(copying: newElements) } #endif diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+Container.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+Container.swift index 53116a7c..11f16424 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+Container.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+Container.swift @@ -20,16 +20,16 @@ import ContainersPreview #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension UniqueArray: Iterable_ where Element: ~Copyable { - public typealias BorrowingIterator_ = Span.BorrowingIterator_ +extension UniqueArray: Iterable where Element: ~Copyable { + public typealias BorrowingIterator = Span.BorrowingIterator @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @_alwaysEmitIntoClient @inline(__always) - public func makeBorrowingIterator_() -> BorrowingIterator_ { - self._storage.makeBorrowingIterator_() + public func makeBorrowingIterator() -> BorrowingIterator { + self._storage.makeBorrowingIterator() } } #endif @@ -41,13 +41,13 @@ extension UniqueArray: Container where Element: ~Copyable { @_lifetime(borrow self) public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { _storage.makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { - _storage.currentIndex(of: iterator) + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + _storage.currentIndex(of: &iterator) } } diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+Initializers.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+Initializers.swift index ce4ce62a..556afc57 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+Initializers.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+Initializers.swift @@ -97,11 +97,11 @@ extension UniqueArray /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init( + public init( capacity: Int? = nil, copying contents: borrowing Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { self.init(minimumCapacity: capacity ?? 0) try self.append(copying: contents) } @@ -135,11 +135,11 @@ extension UniqueArray /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int? = nil, copying contents: Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { self.init(minimumCapacity: capacity ?? 0) try self.append(copying: contents) } diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift index 9cc21b7a..eef01665 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift @@ -19,15 +19,14 @@ import ContainersPreview #if compiler(>=6.4) && UnstableHashedContainers && UnstableContainersPreview @available(SwiftStdlib 5.0, *) -extension UniqueSet: Iterable_ where Element: ~Copyable { - public typealias Element_ = Element - public typealias BorrowingIterator_ = RigidSet.BorrowingIterator_ +extension UniqueSet: Iterable where Element: ~Copyable { + public typealias BorrowingIterator = RigidSet.BorrowingIterator @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @inlinable - public func _customContainsEquatableElement_( + public func _customContainsEquatableElement( _ element: borrowing Element ) -> Bool? { self.contains(element) @@ -35,8 +34,8 @@ extension UniqueSet: Iterable_ where Element: ~Copyable { @inlinable @_lifetime(borrow self) - public borrowing func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(_set: _storage) + public borrowing func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(_set: _storage) } } #endif diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift index a4b65a36..930afaa5 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift @@ -77,12 +77,10 @@ extension UniqueSet where Element: Copyable { #if UnstableContainersPreview @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public init< - S: Iterable_ & ~Copyable & ~Escapable - >( + public init( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init() try self.insert(copying: items) } @@ -97,12 +95,10 @@ extension UniqueSet where Element: Copyable { #if UnstableContainersPreview @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public init< - S: Iterable_ & Sequence - >( + public init>( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init() try self._insert(copying: items) } diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift index ac095a70..a7c64e57 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift @@ -134,15 +134,15 @@ extension UniqueSet /* where Element: Copyable */ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient package mutating func _insert< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { - _ensureFreeCapacity(items.underestimatedCount_) - var it = items.makeBorrowingIterator_() + ) throws(S.Failure) + where S.Element == Element { + _ensureFreeCapacity(items.underestimatedCount) + var it = items.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() guard !span.isEmpty else { break } self.insert(copying: span) } @@ -154,10 +154,10 @@ extension UniqueSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public mutating func insert< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) where S.Element_ == Element { + ) throws(S.Failure) where S.Element == Element { try _insert(copying: items) } #endif @@ -177,11 +177,11 @@ extension UniqueSet /* where Element: Copyable */ { @_alwaysEmitIntoClient @inline(__always) public mutating func insert< - S: Iterable_ & Sequence + S: Iterable & Sequence >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try _insert(copying: items) } #endif diff --git a/Sources/ContainersPreview/CMakeLists.txt b/Sources/ContainersPreview/CMakeLists.txt index 35317ad1..e0c8557b 100644 --- a/Sources/ContainersPreview/CMakeLists.txt +++ b/Sources/ContainersPreview/CMakeLists.txt @@ -27,16 +27,12 @@ endif() target_sources(${module_name} PRIVATE "Conformances/Array+Iterable.swift" "Conformances/ClosedRange+Iterable.swift" - "Conformances/InlineArray+Iterable.swift" "Conformances/InputSpan+Container.swift" "Conformances/InputSpan+Iterable.swift" "Conformances/MutableSpan+Container.swift" - "Conformances/MutableSpan+Iterable.swift" "Conformances/OutputSpan+Container.swift" - "Conformances/OutputSpan+Iterable.swift" "Conformances/Range+Iterable.swift" "Conformances/Span+Container.swift" - "Conformances/Span+Iterable.swift" "Protocols/Container/BidirectionalContainer.swift" "Protocols/Container/Container.swift" "Protocols/Container/Container+Filter.swift" @@ -57,7 +53,6 @@ target_sources(${module_name} PRIVATE "Protocols/BorrowingIteratorProtocol+MapError.swift" "Protocols/BorrowingIteratorProtocol+Reduce.swift" "Protocols/BorrowingIteratorProtocol+SpanwiseZip.swift" - "Protocols/Iterable.swift" "Protocols/Iterable+Algorithms.swift" "Protocols/Iterable+Utilities.swift" "Protocols/CountedProducer.swift" diff --git a/Sources/ContainersPreview/Conformances/Array+Iterable.swift b/Sources/ContainersPreview/Conformances/Array+Iterable.swift index 5d6f4b2b..f7851176 100644 --- a/Sources/ContainersPreview/Conformances/Array+Iterable.swift +++ b/Sources/ContainersPreview/Conformances/Array+Iterable.swift @@ -14,17 +14,16 @@ #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension Array: Iterable_ { - public typealias Element_ = Element - public typealias BorrowingIterator_ = Span.BorrowingIterator_ +extension Array: @retroactive Iterable { + public typealias BorrowingIterator = Span.BorrowingIterator @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @_lifetime(borrow self) @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self.span) + public func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(self.span) } } diff --git a/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift b/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift index c4e199b2..f63c7f01 100644 --- a/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift +++ b/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift @@ -14,13 +14,13 @@ #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.2, *) -extension ClosedRange: Iterable_ +extension ClosedRange: @retroactive Iterable where Bound: Strideable, Bound.Stride: SignedInteger { - public typealias Element_ = Bound + public typealias Element = Bound @frozen - public struct BorrowingIterator_: BorrowingIteratorProtocol_, ~Copyable { + public struct BorrowingIterator: BorrowingIteratorProtocol, ~Copyable { @usableFromInline internal var _current: InlineArray<1, Bound> @@ -38,7 +38,7 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { if _progress { _current[0] = _current[0].advanced(by: 1) } @@ -52,7 +52,7 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable - public var underestimatedCount_: Int { + public var underestimatedCount: Int { guard let distance = Int(exactly: lowerBound.distance(to: upperBound)) else { return 0 } let advanced = distance.addingReportingOverflow(1) @@ -61,8 +61,8 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self) + public func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(self) } } diff --git a/Sources/ContainersPreview/Conformances/InlineArray+Iterable.swift b/Sources/ContainersPreview/Conformances/InlineArray+Iterable.swift deleted file mode 100644 index b503e97d..00000000 --- a/Sources/ContainersPreview/Conformances/InlineArray+Iterable.swift +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2026 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception -// -//===----------------------------------------------------------------------===// - -#if compiler(>=6.4) && UnstableContainersPreview - -@available(SwiftStdlib 6.4, *) -extension InlineArray: Iterable_ where Element: ~Copyable { - public typealias Element_ = Element - public typealias BorrowingIterator_ = Span.BorrowingIterator_ - - @inlinable - public var underestimatedCount_: Int { count } - - @_lifetime(borrow self) - @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self.span) - } -} - -#endif diff --git a/Sources/ContainersPreview/Conformances/InputSpan+Container.swift b/Sources/ContainersPreview/Conformances/InputSpan+Container.swift index 6a88e605..f907bf9c 100644 --- a/Sources/ContainersPreview/Conformances/InputSpan+Container.swift +++ b/Sources/ContainersPreview/Conformances/InputSpan+Container.swift @@ -25,7 +25,7 @@ where Element: ~Copyable public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { let span = self.span let it = span.makeBorrowingIterator(from: start, to: end) // FIXME: `it` is borrowing `span`, not self @@ -33,8 +33,8 @@ where Element: ~Copyable } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { - self.span.currentIndex(of: iterator) + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + self.span.currentIndex(of: &iterator) } } #endif diff --git a/Sources/ContainersPreview/Conformances/InputSpan+Iterable.swift b/Sources/ContainersPreview/Conformances/InputSpan+Iterable.swift index 98d1d49c..333bb961 100644 --- a/Sources/ContainersPreview/Conformances/InputSpan+Iterable.swift +++ b/Sources/ContainersPreview/Conformances/InputSpan+Iterable.swift @@ -14,16 +14,16 @@ #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension InputSpan: Iterable_ where Element: ~Copyable { - public typealias BorrowingIterator_ = Span.BorrowingIterator_ +extension InputSpan: Iterable where Element: ~Copyable { + public typealias BorrowingIterator = Span.BorrowingIterator @inlinable - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @_lifetime(borrow self) @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self.span) + public func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(self.span) } } diff --git a/Sources/ContainersPreview/Conformances/MutableSpan+Container.swift b/Sources/ContainersPreview/Conformances/MutableSpan+Container.swift index ed5625ff..b4432051 100644 --- a/Sources/ContainersPreview/Conformances/MutableSpan+Container.swift +++ b/Sources/ContainersPreview/Conformances/MutableSpan+Container.swift @@ -22,19 +22,16 @@ extension MutableSpan: RandomAccessContainer where Element: ~Copyable { @_lifetime(borrow self) public func makeBorrowingIterator( from start: Int, to end: Int - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { // FIXME: `makeBorrowingIterator` would be borrowing the temporary `span`, not self self.span._makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient public func currentIndex( - of iterator: borrowing BorrowingIterator_ + of iterator: inout BorrowingIterator ) -> Int { - precondition( - self.span.isTriviallyIdentical(to: iterator._span), - "Invalid iterator") - return iterator._start + self.span.currentIndex(of: &iterator) } } #endif diff --git a/Sources/ContainersPreview/Conformances/MutableSpan+Iterable.swift b/Sources/ContainersPreview/Conformances/MutableSpan+Iterable.swift deleted file mode 100644 index d736962f..00000000 --- a/Sources/ContainersPreview/Conformances/MutableSpan+Iterable.swift +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2026 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception -// -//===----------------------------------------------------------------------===// - -#if compiler(>=6.4) && UnstableContainersPreview - -@available(SwiftStdlib 6.4, *) -extension MutableSpan: Iterable_ where Element: ~Copyable { - public typealias BorrowingIterator_ = Span.BorrowingIterator_ - public typealias Element_ = Element - - @inlinable - public var underestimatedCount_: Int { count } - - @_lifetime(borrow self) - @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - // FIXME: This should be declared to return BorrowingIterator, but it - // clashes with the stdlib's alternate definition: - // error: 'BorrowingIterator' is ambiguous for type lookup in this context - // Two different typealiases with the same name wreaks havoc with inference? - BorrowingIterator_(self.span) - } -} - -#endif diff --git a/Sources/ContainersPreview/Conformances/OutputSpan+Container.swift b/Sources/ContainersPreview/Conformances/OutputSpan+Container.swift index f048680a..899c7a2f 100644 --- a/Sources/ContainersPreview/Conformances/OutputSpan+Container.swift +++ b/Sources/ContainersPreview/Conformances/OutputSpan+Container.swift @@ -18,20 +18,20 @@ import InternalCollectionsUtilities #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) extension OutputSpan: RandomAccessContainer, MutableContainer -where Element: ~Copyable +/*where Element: ~Copyable*/ // FIXME: rdar://183153655 OutputSpan's Iterable conformance requires Element to be Copyable { @_alwaysEmitIntoClient @_lifetime(borrow self) public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { // FIXME: `makeBorrowingIterator` would be borrowing the temporary `span`, not self self.span._makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { - self.span.currentIndex(of: iterator) + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + self.span.currentIndex(of: &iterator) } @_alwaysEmitIntoClient diff --git a/Sources/ContainersPreview/Conformances/OutputSpan+Iterable.swift b/Sources/ContainersPreview/Conformances/OutputSpan+Iterable.swift deleted file mode 100644 index 60f6f170..00000000 --- a/Sources/ContainersPreview/Conformances/OutputSpan+Iterable.swift +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2026 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception -// -//===----------------------------------------------------------------------===// - -#if compiler(>=6.4) && UnstableContainersPreview - -@available(SwiftStdlib 6.4, *) -extension OutputSpan: Iterable_ where Element: ~Copyable { - public typealias Element_ = Element - public typealias BorrowingIterator_ = Span.BorrowingIterator_ - - @inlinable - public var underestimatedCount_: Int { count } - - @_lifetime(borrow self) - @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self.span) - } -} - -#endif diff --git a/Sources/ContainersPreview/Conformances/Range+Iterable.swift b/Sources/ContainersPreview/Conformances/Range+Iterable.swift index d44995dc..5da241fd 100644 --- a/Sources/ContainersPreview/Conformances/Range+Iterable.swift +++ b/Sources/ContainersPreview/Conformances/Range+Iterable.swift @@ -14,13 +14,13 @@ #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension Range: Iterable_ +extension Range: @retroactive Iterable where Bound: Strideable, Bound.Stride: SignedInteger { - public typealias Element_ = Bound + public typealias Element = Bound @frozen - public struct BorrowingIterator_: BorrowingIteratorProtocol_, ~Copyable { + public struct BorrowingIterator: BorrowingIteratorProtocol, ~Copyable { @usableFromInline internal var _current: InlineArray<1, Bound> @@ -38,7 +38,7 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { if _progress { _current[0] = _current[0].advanced(by: 1) } @@ -52,7 +52,7 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable - public var underestimatedCount_: Int { + public var underestimatedCount: Int { guard let count = Int(exactly: lowerBound.distance(to: upperBound)) else { return 0 } @@ -60,8 +60,8 @@ where Bound: Strideable, Bound.Stride: SignedInteger } @inlinable - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self) + public func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(self) } } diff --git a/Sources/ContainersPreview/Conformances/Span+Container.swift b/Sources/ContainersPreview/Conformances/Span+Container.swift index 95fac5e1..a27c646a 100644 --- a/Sources/ContainersPreview/Conformances/Span+Container.swift +++ b/Sources/ContainersPreview/Conformances/Span+Container.swift @@ -11,30 +11,66 @@ // //===----------------------------------------------------------------------===// +@_frozen +@usableFromInline +package struct _ShamSpanIterator { + // FIXME: Remove this when `Span.BorrowingIterator` becomes actually usable. + @_alwaysEmitIntoClient + internal var _basePointer: UnsafeRawPointer? + + @_alwaysEmitIntoClient + internal var _baseCount: Int + + @_alwaysEmitIntoClient + internal var _start: Int + + @_alwaysEmitIntoClient + internal var _count: Int +} + #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) extension Span: RandomAccessContainer where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(copy self) - package func _makeBorrowingIterator(from start: Int, to end: Int) -> BorrowingIterator_ { + package func _makeBorrowingIterator(from start: Int, to end: Int) -> BorrowingIterator { // Note: This is declared `copy self` so that types can forward to it without having to override lifetimes. - // FIXME: SpanIterator needs to have a public "slicing" initializer - BorrowingIterator_(self, from: start, to: end) + #if false // FIXME: Span's iterator needs to provide a public "slicing" initializer + return BorrowingIterator(self, from: start, to: end) + #else + var it = BorrowingIterator(self.extracting(first: end)) + let c = it.skip(by: start) + precondition(c == start) + return it + #endif } @_alwaysEmitIntoClient @_lifetime(borrow self) - public func makeBorrowingIterator(from start: Int, to end: Int) -> BorrowingIterator_ { + public func makeBorrowingIterator(from start: Int, to end: Int) -> BorrowingIterator { _makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Int { - // FIXME: SpanIterator needs to have public `base` and `position` properties + public func currentIndex(of iterator: inout BorrowingIterator) -> Int { + #if false // FIXME: SpanIterator needs to provide public `base` and `position` properties precondition( self.isTriviallyIdentical(to: iterator._span), - "Invalid iterator") + "Iterator does not belong to this container") return iterator._start + #else + precondition(MemoryLayout.stride == MemoryLayout<_ShamSpanIterator>.stride) + return self.withUnsafeBufferPointer { ourBuffer in + Swift.withUnsafeBytes(of: &iterator) { buffer in + buffer.withMemoryRebound(to: _ShamSpanIterator.self) { shamBuffer in + precondition( + shamBuffer[0]._basePointer == UnsafeRawPointer(ourBuffer.baseAddress) && shamBuffer[0]._baseCount <= ourBuffer.count, + "Iterator does not belong to this container") + return shamBuffer[0]._start + } + } + } + #endif } } #endif diff --git a/Sources/ContainersPreview/Conformances/Span+Iterable.swift b/Sources/ContainersPreview/Conformances/Span+Iterable.swift deleted file mode 100644 index f841bc26..00000000 --- a/Sources/ContainersPreview/Conformances/Span+Iterable.swift +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2026 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception -// -//===----------------------------------------------------------------------===// - -#if compiler(>=6.4) && UnstableContainersPreview - -@available(SwiftStdlib 6.4, *) -extension Span: Iterable_ where Element: ~Copyable { - public typealias Element_ = Element - - @inlinable - public var underestimatedCount_: Int { count } - - @inlinable - @_lifetime(borrow self) - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(self) - } -} - -@available(SwiftStdlib 5.0, *) -extension Span where Element: ~Copyable { - /// A borrowing iterator that provides access to the elements of a single - /// span through a `BorrowingIteratorProtocol` interface. - @available(SwiftStdlib 6.4, *) - public struct BorrowingIterator_: - BorrowingIteratorProtocol_, ~Copyable, ~Escapable - { - public typealias Element_ = Element - - @usableFromInline - package var _span: Span - @usableFromInline - package var _start: Int - @usableFromInline - package var _count: Int - - @_lifetime(copy elements) - public init(_ elements: Span) { - _span = elements - _start = 0 - _count = elements.count - } - - @_lifetime(copy elements) - public init(_ elements: Span, from start: Int, to end: Int) { - precondition(start >= 0 && start <= elements.count, "Index out of bounds") - precondition(end >= 0 && end <= elements.count, "Index out of bounds") - precondition(start <= end, "start index must be less than or equal to end index") - _span = elements - _start = start - _count = end &- start - } - - @_alwaysEmitIntoClient - @_lifetime(&self) - @_lifetime(self: copy self) - @_transparent - public mutating func nextSpan_(maxCount: Int) -> Span { - let c = Swift.min(maxCount, _count) - defer { - _start &+= c - _count &-= c - } - return _span.extracting(droppingFirst: _start).extracting(first: c) - } - - @_alwaysEmitIntoClient - @_lifetime(self: copy self) - public mutating func skip_(by offset: Int) -> Int { - let c = Swift.min(offset, _count) - defer { - _start &+= c - _count &-= c - } - return c - } - } -} -#endif diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Copy.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Copy.swift index 9831a128..fbe4d4ec 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Copy.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Copy.swift @@ -13,11 +13,11 @@ #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: Copyable + Element: Copyable { /// Turns a borrowing iterator into a producer by copying its elements. /// This allows producer algorithms (such as `collect(into:)`) to get @@ -25,7 +25,7 @@ where /// will get copied. @inlinable @_lifetime(copy self) - public consuming func copy() -> BorrowingMapProducer { + public consuming func copy() -> BorrowingMapProducer { // FIXME: We could also just define a direct implementation that avoids the closure. self.map { $0 } } diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+ElementsEqual.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+ElementsEqual.swift index d2f57623..adcfb388 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+ElementsEqual.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+ElementsEqual.swift @@ -18,30 +18,30 @@ import InternalCollectionsUtilities #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension Iterable_ +extension Iterable where - Self: ~Copyable & ~Escapable, Element_: Equatable, - Element_: ~Copyable + Self: ~Copyable & ~Escapable, Element: Equatable, + Element: ~Copyable { @inlinable package func _elementsEqual< - Other: Iterable_ & ~Copyable & ~Escapable + Other: Iterable & ~Copyable & ~Escapable >( _ other: borrowing Other, - ) throws(Failure_) -> Bool - where Other.Element_: ~Copyable + ) throws(Failure) -> Bool + where Other.Element: ~Copyable { - let it1 = self.makeBorrowingIterator_() - let it2 = other.makeBorrowingIterator_() + let it1 = self.makeBorrowingIterator() + let it2 = other.makeBorrowingIterator() return try it1.elementsEqual(it2) } } @available(SwiftStdlib 6.4, *) -extension Iterable_ +extension Iterable where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { /// Returns a Boolean value indicating whether two borrowing sequences contain /// equivalent elements in the same order, using the given predicate as the @@ -66,32 +66,32 @@ where /// - Complexity: O(*m*), where *m* is the count of the longer of the input sequences. @inlinable package func _elementsEqual< - Other: Iterable_ & ~Copyable & ~Escapable + Other: Iterable & ~Copyable & ~Escapable >( _ other: borrowing Other, - by areEquivalent: (borrowing Element_, borrowing Other.Element_) throws(Failure_) -> Bool - ) throws(Failure_) -> Bool - where Other.Element_: ~Copyable, Other.Failure_ == Failure_ + by areEquivalent: (borrowing Element, borrowing Other.Element) throws(Failure) -> Bool + ) throws(Failure) -> Bool + where Other.Element: ~Copyable, Other.Failure == Failure { - let it1 = self.makeBorrowingIterator_() - let it2 = other.makeBorrowingIterator_() + let it1 = self.makeBorrowingIterator() + let it2 = other.makeBorrowingIterator() return try it1.elementsEqual(it2, by: areEquivalent) } } @available(SwiftStdlib 6.4, *) -extension BorrowingIteratorProtocol_ +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable & Equatable + Element: ~Copyable & Equatable { @inlinable package consuming func elementsEqual< - Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable + Other: BorrowingIteratorProtocol & ~Copyable & ~Escapable >( _ other: consuming Other, - ) throws(Failure_) -> Bool - where Other.Element_: ~Copyable + ) throws(Failure) -> Bool + where Other.Element: ~Copyable { var result = true try _spanwiseZip(state: &result, with: other) { state, a, b in @@ -113,11 +113,11 @@ where @inlinable package consuming func _directElementsEqual< - Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable + Other: BorrowingIteratorProtocol & ~Copyable & ~Escapable >( _ other: consuming Other, - ) throws(Failure_) -> Bool - where Other.Element_: ~Copyable + ) throws(Failure) -> Bool + where Other.Element: ~Copyable { #if true // FIXME: rdar://150228920 Exclusive access scopes aren't expanded enough // Note: This is the less efficient implementation of elementsEqual. The @@ -125,13 +125,13 @@ where // (It lets the two iterators run at their native speeds, with no artificial // maxCounts.) while true { - let a = try self.nextSpan_() + let a = try self.nextSpan() var i = 0 if a.isEmpty { - return try other.nextSpan_().isEmpty + return try other.nextSpan().isEmpty } while i < a.count { - let b = try other.nextSpan_(maxCount: a.count - i) + let b = try other.nextSpan(maxCount: a.count - i) if b.isEmpty { return false } @@ -174,22 +174,22 @@ where } @available(SwiftStdlib 6.4, *) -extension BorrowingIteratorProtocol_ +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable package consuming func elementsEqual< - Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable + Other: BorrowingIteratorProtocol & ~Copyable & ~Escapable >( _ other: consuming Other, - by areEquivalent: (borrowing Element_, borrowing Other.Element_) throws(Failure_) -> Bool - ) throws(Failure_) -> Bool - where Other.Element_: ~Copyable, Other.Failure_ == Failure_ + by areEquivalent: (borrowing Element, borrowing Other.Element) throws(Failure) -> Bool + ) throws(Failure) -> Bool + where Other.Element: ~Copyable, Other.Failure == Failure { var result = true - try _spanwiseZip(state: &result, with: other) { state, a, b throws(Failure_) in + try _spanwiseZip(state: &result, with: other) { state, a, b throws(Failure) in assert(a.count == b.count || a.isEmpty || b.isEmpty) if a.isEmpty || b.isEmpty { state = false diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Filter.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Filter.swift index c5cc3d96..25fdfe08 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Filter.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Filter.swift @@ -13,31 +13,31 @@ #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable @_lifetime(copy self) public consuming func filter( - _ isIncluded: @escaping (borrowing Element_) -> Bool + _ isIncluded: @escaping (borrowing Element) -> Bool ) -> BorrowingFilter { BorrowingFilter(_base: self, isIncluded: isIncluded) } } -@available(SwiftStdlib 5.0, *) +@available(SwiftStdlib 6.4, *) public struct BorrowingFilter< - Base: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable + Base: BorrowingIteratorProtocol & ~Copyable & ~Escapable >: ~Copyable, ~Escapable -where Base.Element_: ~Copyable { - public typealias Element_ = Base.Element_ - public typealias Failure = Base.Failure_ +where Base.Element: ~Copyable { + public typealias Element = Base.Element + public typealias Failure = Base.Failure @_alwaysEmitIntoClient - public let _isIncluded: (borrowing Element_) throws(Failure) -> Bool + public let _isIncluded: (borrowing Element) throws(Failure) -> Bool @_alwaysEmitIntoClient public var _base: Base @@ -46,7 +46,7 @@ where Base.Element_: ~Copyable { @_lifetime(copy _base) internal init( _base: consuming Base, - isIncluded: @escaping (borrowing Element_) -> Bool + isIncluded: @escaping (borrowing Element) -> Bool ) { self._isIncluded = isIncluded self._base = _base @@ -55,14 +55,14 @@ where Base.Element_: ~Copyable { // FIXME: Sendable -@available(SwiftStdlib 5.0, *) -extension BorrowingFilter: BorrowingIteratorProtocol_ -where Base: ~Copyable & ~Escapable, Base.Element_: ~Copyable { +@available(SwiftStdlib 6.4, *) +extension BorrowingFilter: BorrowingIteratorProtocol +where Base: ~Copyable & ~Escapable, Base.Element: ~Copyable { @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) throws(Failure) -> Span { + public mutating func nextSpan(maxCount: Int) throws(Failure) -> Span { // FIXME: This is quite inefficient compared to Container's filter while true { - let span = try _base.nextSpan_(maxCount: 1) + let span = try _base.nextSpan(maxCount: 1) if span.isEmpty { return span } precondition(span.count == 1, "Invalid BorrowingIterator") if try _isIncluded(span[unchecked: 0]) { return span } diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Map.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Map.swift index 35d6fd4f..425c3fc1 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Map.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Map.swift @@ -13,20 +13,20 @@ #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable @_lifetime(copy self) public consuming func map( - _ transform: @escaping (borrowing Element_) -> T + _ transform: @escaping (borrowing Element) -> T ) -> BorrowingMapProducer { BorrowingMapProducer( _base: self, - transform: { v throws(Failure_) in + transform: { v throws(Failure) in // FIXME: Conversion from non-throwing to throwing closure should be implicit transform(v) }) @@ -35,7 +35,7 @@ where @inlinable @_lifetime(copy self) public consuming func map2( // FIXME: We can't overload on the type of error thrown. - _ transform: @escaping (borrowing Element_) throws(Failure_) -> T + _ transform: @escaping (borrowing Element) throws(Failure) -> T ) -> BorrowingMapProducer { BorrowingMapProducer(_base: self, transform: transform) } @@ -43,20 +43,20 @@ where @inlinable @_lifetime(copy self) public consuming func map2( // FIXME: We can't overload on the type of error thrown. - _ transform: @escaping (borrowing Element_) throws(E) -> T + _ transform: @escaping (borrowing Element) throws(E) -> T ) -> BorrowingMapProducer, T> - where Failure_ == Never { + where Failure == Never { BorrowingMapProducer(_base: self.mapError(), transform: transform) } } -@available(SwiftStdlib 5.0, *) +@available(SwiftStdlib 6.4, *) public struct BorrowingMapProducer< - Base: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable, + Base: BorrowingIteratorProtocol & ~Copyable & ~Escapable, Element: ~Copyable, >: ~Copyable, ~Escapable { @_alwaysEmitIntoClient - public let _transform: (borrowing Base.Element_) throws(Failure) -> Element + public let _transform: (borrowing Base.Element) throws(Failure) -> Element @_alwaysEmitIntoClient public var _it: Base @@ -65,7 +65,7 @@ public struct BorrowingMapProducer< @_lifetime(copy _base) internal init( _base: consuming Base, - transform: @escaping (borrowing Base.Element_) throws(Failure) -> Element + transform: @escaping (borrowing Base.Element) throws(Failure) -> Element ) { self._transform = transform self._it = _base @@ -74,13 +74,13 @@ public struct BorrowingMapProducer< // FIXME: Sendable -@available(SwiftStdlib 5.0, *) +@available(SwiftStdlib 6.4, *) extension BorrowingMapProducer: Producer where Base: ~Copyable & ~Escapable, Element: ~Copyable { - public typealias Failure = Base.Failure_ + public typealias Failure = Base.Failure @inlinable public var underestimatedCount: Int { @@ -90,7 +90,7 @@ where @inlinable @_lifetime(self: copy self) public mutating func next() throws(Failure) -> Element? { - let span = try _it.nextSpan_(maxCount: 1) + let span = try _it.nextSpan(maxCount: 1) guard !span.isEmpty else { return nil } return try _transform(span[unchecked: 0]) } @@ -104,7 +104,7 @@ where ) throws(Failure) -> Bool { var success = false while !target.isFull { - let span = try _it.nextSpan_(maxCount: target.freeCapacity) + let span = try _it.nextSpan(maxCount: target.freeCapacity) guard !span.isEmpty else { break } success = true var i = 0 @@ -121,18 +121,18 @@ where public mutating func skip(by n: inout Int) throws(Failure) { precondition(n > 0, "Can't skip a negative number of elements") if Failure.self == Never.self { - n -= try! _it.skip_(by: n) + n -= try! _it.skip(by: n) return } #if false // FIXME: Iterator's ill-conceived skip(by:) fails to report the position that triggers errors - try _it.skip_(by: &n) + try _it.skip(by: &n) #else // We have no choice other than skipping items one by one, or allowing // the base to materialize every element. The latter performs better in // the common case of containers, so let's do that. while n > 0 { - let span = try _it.nextSpan_(maxCount: n) + let span = try _it.nextSpan(maxCount: n) n -= span.count } #endif diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+MapError.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+MapError.swift index 292db26e..a6fb8e88 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+MapError.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+MapError.swift @@ -13,16 +13,16 @@ #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable @_lifetime(copy self) public consuming func mapError( - _ transform: @escaping (Failure_) -> NewFailure + _ transform: @escaping (Failure) -> NewFailure ) -> ErrorMappedIterator { ErrorMappedIterator(base: self, transform: transform) } @@ -32,21 +32,22 @@ where public consuming func mapError( to error: NewFailure.Type = NewFailure.self ) -> ErrorMappedIterator - where Failure_ == Never { + where Failure == Never { ErrorMappedIterator(base: self, transform: { _ in fatalError("Unreachable") }) } } +@available(SwiftStdlib 6.4, *) @frozen public struct ErrorMappedIterator< - Base: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable, + Base: BorrowingIteratorProtocol & ~Copyable & ~Escapable, Failure: Error >: ~Copyable, ~Escapable -where Base.Element_: ~Copyable { +where Base.Element: ~Copyable { @usableFromInline - internal let _transform: (Base.Failure_) -> Failure + internal let _transform: (Base.Failure) -> Failure @usableFromInline internal var _base: Base @@ -55,27 +56,28 @@ where Base.Element_: ~Copyable { @_lifetime(copy base) public init( base: consuming Base, - transform: @escaping (Base.Failure_) -> Failure + transform: @escaping (Base.Failure) -> Failure ) { self._base = base self._transform = transform } } -extension ErrorMappedIterator: BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension ErrorMappedIterator: BorrowingIteratorProtocol where Base: ~Copyable & ~Escapable, - Base.Element_: ~Copyable + Base.Element: ~Copyable { - public typealias Element_ = Base.Element_ - public typealias Failure_ = Failure + public typealias Element = Base.Element + public typealias Failure = Failure @inlinable @_lifetime(&self) @_lifetime(self: copy self) - public mutating func nextSpan_(maxCount: Int) throws(Failure_) -> Span { + public mutating func nextSpan(maxCount: Int) throws(Failure) -> Span { do { - return try _base.nextSpan_(maxCount: maxCount) + return try _base.nextSpan(maxCount: maxCount) } catch { throw _transform(error) } @@ -83,9 +85,9 @@ where @inlinable @_lifetime(self: copy self) - public mutating func skip_(by maximumOffset: Int) throws(Failure_) -> Int { + public mutating func skip(by maximumOffset: Int) throws(Failure) -> Int { do { - return try _base.skip_(by: maximumOffset) + return try _base.skip(by: maximumOffset) } catch { throw _transform(error) } diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Reduce.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Reduce.swift index 6f766bb2..62b07169 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Reduce.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+Reduce.swift @@ -13,20 +13,20 @@ #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable public consuming func reduce( _ initialResult: consuming Result, - _ nextPartialResult: (consuming Result, borrowing Element_) throws(Failure_) -> Result - ) throws(Failure_) -> Result { + _ nextPartialResult: (consuming Result, borrowing Element) throws(Failure) -> Result + ) throws(Failure) -> Result { var result = initialResult while true { - let span = try self.nextSpan_() + let span = try self.nextSpan() guard !span.isEmpty else { break } var i = 0 while i < span.count { @@ -40,11 +40,11 @@ where @inlinable public consuming func reduce( into initialResult: consuming Result, - _ updateAccumulatingResult: (inout Result, borrowing Element_) throws(Failure_) -> Void - ) throws(Failure_) -> Result { + _ updateAccumulatingResult: (inout Result, borrowing Element) throws(Failure) -> Void + ) throws(Failure) -> Result { var result = initialResult while true { - let span = try self.nextSpan_() + let span = try self.nextSpan() guard !span.isEmpty else { break } var i = 0 while i < span.count { diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+SpanwiseZip.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+SpanwiseZip.swift index 393f2023..412b923b 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+SpanwiseZip.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol+SpanwiseZip.swift @@ -17,22 +17,22 @@ import InternalCollectionsUtilities #if compiler(>=6.4) && UnstableContainersPreview -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, - Element_: ~Copyable + Element: ~Copyable { @inlinable internal consuming func _spanwiseZip< - Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable, + Other: BorrowingIteratorProtocol & ~Copyable & ~Escapable, State: ~Copyable >( state: inout State, with other: consuming Other, - by process: (inout State, Span, Span) throws(Failure_) -> Bool - ) throws(Failure_) - where Other.Element_: ~Copyable, Other.Failure_ == Failure_ + by process: (inout State, Span, Span) throws(Failure) -> Bool + ) throws(Failure) + where Other.Element: ~Copyable, Other.Failure == Failure { #if true // FIXME: rdar://150228920 Exclusive access scopes aren't expanded enough // Note: This is the less efficient implementation of spanwiseZip. The @@ -41,17 +41,17 @@ where // maxCounts.) loop: while true { - var a = try self.nextSpan_() + var a = try self.nextSpan() if a.isEmpty { while true { - let b = try other.nextSpan_() + let b = try other.nextSpan() guard !b.isEmpty else { break } guard try process(&state, a, b) else { break } } return } repeat { - let b = try other.nextSpan_(maxCount: a.count) + let b = try other.nextSpan(maxCount: a.count) if b.isEmpty { guard try process(&state, a, b) else { return } } else { diff --git a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol.swift b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol.swift index b8009880..79584964 100644 --- a/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol.swift +++ b/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol.swift @@ -17,126 +17,32 @@ import InternalCollectionsUtilities #endif -@available(SwiftStdlib 5.0, *) -public protocol BorrowingIteratorProtocol_: ~Copyable, ~Escapable { - associatedtype Element_: ~Copyable - associatedtype Failure_: Error = Never - - /// Advance the iterator, returning an ephemeral span over the elements - /// that are ready to be visited. - /// - /// If the underlying sequence is a container type, then the returned span - /// typically directly addresses one of its storage buffers. On the other - /// hand, if the underlying sequence materializes its elements on demand, - /// then the returned span addresses some temporary buffer associated with - /// the iterator itself. Consequently, the returned span is tied to this - /// particular invocation of `nextSpan`, and it cannot survive until the next - /// invocation of it. - /// - /// If the iterator has not yet reached the end of the underlying sequence, - /// then this method returns a non-empty span of at most `maxCount` - /// elements, and updates the iterator's current position to the element - /// following the last item in the returned span (or the end, if there is - /// none). The `maxCount` argument allows callers to avoid getting more - /// items that they are able to process in one go, simplifying usage, and - /// avoiding materializing more elements than needed. - /// - /// If the iterator's current position is at the end of the container, then - /// this method returns an empty span without updating the position. - /// - /// This method can be used to efficiently process the items of a container - /// in bulk, by directly iterating over its piecewise contiguous pieces of - /// storage: - /// - /// var it = items.makeBorrowingIterator() - /// while true { - /// let span = it.nextSpan(after: &index) - /// if span.isEmpty { break } - /// // Process items in `span` - /// } - /// - /// Note: The spans returned by this method are not guaranteed to be disjunct. - /// Iterators that materialize elements on demand typically reuse the same - /// buffer over and over again; and even some proper containers may link to a - /// single storage chunk (or parts of a storage chunk) multiple times, for - /// example to repeat their contents. - /// - /// Note: Repeatedly iterating over the same container is expected to return - /// the same items (collected in similarly sized span instances), but the - /// returned spans are not guaranteed to be identical. For example, this is - /// the case with containers that store some of their contents within their - /// direct representation. Such containers may not always have a unique - /// address in memory, and so the locations of the spans exposed by this - /// method may vary between different borrows of the same container.) - @_lifetime(&self) - @_lifetime(self: copy self) - mutating func nextSpan_(maxCount: Int) throws(Failure_) -> Span - - /// Advance the position of this iterator by the specified offset, or until - /// the end of the underlying sequence. - /// - /// Returns the number of items that were skipped. If this is less than - /// `maximumOffset`, then the sequence did not have enough elements left to - /// skip the requested number of items. In this case, the iterator's current - /// position is set to the end of the sequence. - /// - /// `maximumOffset` must be nonnegative. - @_lifetime(self: copy self) - mutating func skip_(by maximumOffset: Int) throws(Failure_) -> Int -} - -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ -where Self: ~Copyable & ~Escapable, Element_: ~Copyable { - @_lifetime(&self) - @_lifetime(self: copy self) - @_transparent - public mutating func nextSpan_() throws(Failure_) -> Span { - try nextSpan_(maxCount: Int.max) - } -} - -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ -where Self: ~Copyable & ~Escapable, Element_: ~Copyable { - @_lifetime(self: copy self) - @inlinable - public mutating func skip_(by maxDistance: Int) throws(Failure_) -> Int { - var remainder = maxDistance - while remainder > 0 { - let span = try nextSpan_(maxCount: remainder) - if span.isEmpty { break } - remainder &-= span.count - } - return maxDistance &- remainder - } -} - -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ where Self: ~Copyable & ~Escapable { +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol +where Self: ~Copyable & ~Escapable, Element: ~Copyable { @available(SwiftStdlib 6.4, *) @_unsafeNonescapableResult // FIXME: Eep; _overrideLifetime(_:mutating:) doesn't work @_lifetime(&self) @_lifetime(self: copy self) - public mutating func next() throws(Failure_) -> Ref? { - let span = try nextSpan_(maxCount: 1) + public mutating func next() throws(Failure) -> Ref? { + let span = try nextSpan(maxCount: 1) guard !span.isEmpty else { return nil } return Ref(span[unchecked: 0]) } } -@available(SwiftStdlib 5.0, *) -extension BorrowingIteratorProtocol_ - where Self: ~Copyable & ~Escapable, Element_: Copyable +@available(SwiftStdlib 6.4, *) +extension BorrowingIteratorProtocol + where Self: ~Copyable & ~Escapable, Element: Copyable { @_lifetime(self: copy self) @inlinable @_transparent - package mutating func _copyContents_(into target: inout OutputSpan) throws(Failure_) { - try target.withUnsafeMutableBufferPointer { (dst, dstCount) throws(Failure_) -> Void in + package mutating func _copyContents(into target: inout OutputSpan) throws(Failure) { + try target.withUnsafeMutableBufferPointer { (dst, dstCount) throws(Failure) -> Void in var tail = dst._extracting(droppingFirst: dstCount) while !tail.isEmpty { - let src = try nextSpan_(maxCount: tail.count) + let src = try nextSpan(maxCount: tail.count) if src.isEmpty { break } tail._initializeAndDropPrefix(copying: src) dstCount += src.count diff --git a/Sources/ContainersPreview/Protocols/Container/Container+Filter.swift b/Sources/ContainersPreview/Protocols/Container/Container+Filter.swift index 5968aa33..f612bdc5 100644 --- a/Sources/ContainersPreview/Protocols/Container/Container+Filter.swift +++ b/Sources/ContainersPreview/Protocols/Container/Container+Filter.swift @@ -24,7 +24,7 @@ extension Container where Self: ~Copyable /*& ~Escapable*/, Element: ~Copyable { public func _filter( _ isIncluded: @escaping (borrowing Element) -> Bool ) -> ContainerFilter { - ContainerFilter(_base: self, isIncluded: isIncluded) + ContainerFilter(_base: self, isIncluded: isIncluded) } } @@ -35,7 +35,7 @@ extension ContainerIterator where Base.Element: ~Copyable { public func filter( _ isIncluded: @escaping (borrowing Element) -> Bool ) -> ContainerFilter { - ContainerFilter(_base: _base, index: _position, isIncluded: isIncluded) + ContainerFilter(_base: _base, index: _position, isIncluded: isIncluded) } } @@ -88,11 +88,9 @@ where Base.Element: ~Copyable // FIXME: Sendable @available(SwiftStdlib 6.4, *) -extension ContainerFilter: BorrowingIteratorProtocol_ where Element: ~Copyable { - public typealias Element_ = Base.Element - - @_lifetime(&self) // FIXME: This should be `@_lifetime(copy self)` - public mutating func nextSpan_(maxCount: Int) -> Span { +extension ContainerFilter: BorrowingIteratorProtocol where Element: ~Copyable { + @_lifetime(&self) + public mutating func nextSpan(maxCount: Int) -> Span { precondition(maxCount > 0) while true { // Drop filtered out items from prefix of _remainder diff --git a/Sources/ContainersPreview/Protocols/Container/Container.swift b/Sources/ContainersPreview/Protocols/Container/Container.swift index 51c8e534..25c2ea2b 100644 --- a/Sources/ContainersPreview/Protocols/Container/Container.swift +++ b/Sources/ContainersPreview/Protocols/Container/Container.swift @@ -19,8 +19,8 @@ /// nondestructively, and efficiently accessed. @available(SwiftStdlib 6.4, *) public protocol Container: - Iterable_, ~Copyable, ~Escapable - where Element: ~Copyable, Element == Element_, Failure_ == Never + Iterable, ~Copyable, ~Escapable + where Element: ~Copyable, Failure == Never { override associatedtype Element: ~Copyable @@ -45,11 +45,12 @@ public protocol Container: /// - Complexity: Recommended to be O(1); conforming types must clearly /// document deviations from this expectation. @_lifetime(borrow self) - func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator_ + func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator /// - Complexity: Recommended to be O(1); conforming types must clearly /// document deviations from this expectation. - func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index + func currentIndex(of iterator: inout BorrowingIterator) -> Index + // FIXME: `inout` needs to be `borrowing`, but Span's needlessly limited iterator makes that unworkable. /// Complexity: O(1) var isEmpty: Bool { get } @@ -279,19 +280,19 @@ public protocol Container: extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable { @_alwaysEmitIntoClient @_transparent - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } @_alwaysEmitIntoClient @_transparent @_lifetime(borrow self) - public func makeBorrowingIterator_() -> BorrowingIterator_ { + public func makeBorrowingIterator() -> BorrowingIterator { self.makeBorrowingIterator(from: self.startIndex, to: self.endIndex) } @_alwaysEmitIntoClient @_transparent @_lifetime(borrow self) - public func makeBorrowingIterator_(from start: Index) -> BorrowingIterator_ { + public func makeBorrowingIterator(from start: Index) -> BorrowingIterator { self.makeBorrowingIterator(from: start, to: self.endIndex) } } diff --git a/Sources/ContainersPreview/Protocols/Container/ContainerIterator.swift b/Sources/ContainersPreview/Protocols/Container/ContainerIterator.swift index ca71c43f..b88d79ec 100644 --- a/Sources/ContainersPreview/Protocols/Container/ContainerIterator.swift +++ b/Sources/ContainersPreview/Protocols/Container/ContainerIterator.swift @@ -18,11 +18,11 @@ extension Container where Self: ~Copyable /*FIXME: & ~Escapable*/, Element: ~Copyable, - BorrowingIterator_ == ContainerIterator + BorrowingIterator == ContainerIterator { @_alwaysEmitIntoClient @_lifetime(borrow self) - public func makeBorrowingIterator_() -> BorrowingIterator_ { + public func makeBorrowingIterator() -> BorrowingIterator { ContainerIterator( _borrowing: self, from: self.startIndex, @@ -31,12 +31,13 @@ where @_alwaysEmitIntoClient @_lifetime(borrow self) - public func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator_ { + public func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator { ContainerIterator(_borrowing: self, from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + // FIXME: This should validate that the iterator belongs to this container. iterator._position } } @@ -68,17 +69,15 @@ where Base.Element: ~Copyable } @available(SwiftStdlib 6.4, *) -extension ContainerIterator: BorrowingIteratorProtocol_ +extension ContainerIterator: BorrowingIteratorProtocol where Base: ~Copyable /*FIXME: & ~Escapable*/, Base.Element: ~Copyable { - public typealias Element_ = Base.Element - @_alwaysEmitIntoClient @_unsafeNonescapableResult // FIXME: we cannot convert from a borrow to an inout dependence?! @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { _base.value .nextSpan( after: &self._position, @@ -88,7 +87,7 @@ where @_alwaysEmitIntoClient @_lifetime(self: copy self) - public mutating func skip_(by maximumOffset: Int) -> Int { + public mutating func skip(by maximumOffset: Int) -> Int { // FIXME: If we aren't modeling bidirectional iterators, then this should // trap on negative maximumOffsets var n = maximumOffset diff --git a/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift b/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift index dd032b47..e34296d6 100644 --- a/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift +++ b/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift @@ -692,15 +692,15 @@ where copying items: borrowing C, at index: Index ) { - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() insert(addingCount: newCount, at: index) { target in while !target.isFull { - let source = it.nextSpan_(maxCount: target.freeCapacity) + let source = it.nextSpan(maxCount: target.freeCapacity) precondition(!source.isEmpty, "Broken container: mismatching count") target._append(copying: source) } } - precondition(it.nextSpan_().isEmpty, "Broken container: mismatching count") + precondition(it.nextSpan().isEmpty, "Broken container: mismatching count") } @_alwaysEmitIntoClient @@ -813,14 +813,14 @@ where @_alwaysEmitIntoClient package mutating func _appendIterable< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() + ) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() guard !span.isEmpty else { break } self.append(copying: span) } @@ -828,11 +828,11 @@ where @_alwaysEmitIntoClient public mutating func append< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try _appendIterable(copying: items) } @@ -863,11 +863,11 @@ where /// - newElements: The new elements to copy into the container. @_alwaysEmitIntoClient public mutating func append< - Source: Iterable_ & Sequence + Source: Iterable & Sequence >( copying newElements: Source - ) throws(Source.Failure_) - where Source.Element_ == Element { + ) throws(Source.Failure) + where Source.Element == Element { try self._appendIterable(copying: newElements) } } diff --git a/Sources/ContainersPreview/Protocols/Iterable+Algorithms.swift b/Sources/ContainersPreview/Protocols/Iterable+Algorithms.swift index 01780d9c..b1b5920b 100644 --- a/Sources/ContainersPreview/Protocols/Iterable+Algorithms.swift +++ b/Sources/ContainersPreview/Protocols/Iterable+Algorithms.swift @@ -14,74 +14,74 @@ #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension Iterable_ - where Self: ~Copyable & ~Escapable, Element_: ~Copyable +extension Iterable + where Self: ~Copyable & ~Escapable, Element: ~Copyable { @inlinable public func reduce( _ initialResult: consuming Result, _ nextPartialResult: - (_ partialResult: consuming Result, borrowing Element_) throws(Failure_) -> Result - ) throws(Failure_) -> Result { - try makeBorrowingIterator_().reduce(initialResult, nextPartialResult) + (_ partialResult: consuming Result, borrowing Element) throws(Failure) -> Result + ) throws(Failure) -> Result { + try makeBorrowingIterator().reduce(initialResult, nextPartialResult) } @inlinable public func reduce( into initialResult: consuming Result, _ updateAccumulatingResult: - (_ partialResult: inout Result, borrowing Element_) throws(Failure_) -> () - ) throws(Failure_) -> Result { - try makeBorrowingIterator_().reduce(into: initialResult, updateAccumulatingResult) + (_ partialResult: inout Result, borrowing Element) throws(Failure) -> () + ) throws(Failure) -> Result { + try makeBorrowingIterator().reduce(into: initialResult, updateAccumulatingResult) } } // Ambiguity breakers @available(SwiftStdlib 6.4, *) -extension Sequence where Self: Iterable_ { +extension Sequence where Self: Iterable { public func reduce( _ initialResult: consuming Result, _ nextPartialResult: - (_ partialResult: consuming Result, borrowing Element_) throws(Failure_) -> Result - ) throws(Failure_) -> Result { - try makeBorrowingIterator_().reduce(initialResult, nextPartialResult) + (_ partialResult: consuming Result, borrowing Element) throws(Failure) -> Result + ) throws(Failure) -> Result { + try makeBorrowingIterator().reduce(initialResult, nextPartialResult) } @inlinable public func reduce( into initialResult: consuming Result, _ updateAccumulatingResult: - (_ partialResult: inout Result, borrowing Element_) throws(Failure_) -> () - ) throws(Failure_) -> Result { - try makeBorrowingIterator_().reduce(into: initialResult, updateAccumulatingResult) + (_ partialResult: inout Result, borrowing Element) throws(Failure) -> () + ) throws(Failure) -> Result { + try makeBorrowingIterator().reduce(into: initialResult, updateAccumulatingResult) } } @available(SwiftStdlib 6.4, *) -extension Iterable_ - where Self: ~Copyable & ~Escapable, Element_: ~Copyable +extension Iterable + where Self: ~Copyable & ~Escapable, Element: ~Copyable { @inlinable - public func elementsEqual( + public func elementsEqual( _ other: borrowing OtherSequence, - by areEquivalent: (borrowing Element_, borrowing OtherSequence.Element_) throws(Failure_) -> Bool - ) throws(Failure_) -> Bool - where OtherSequence: ~Copyable & ~Escapable, OtherSequence.Element_: ~Copyable, OtherSequence.Failure_ == Failure_ + by areEquivalent: (borrowing Element, borrowing OtherSequence.Element) throws(Failure) -> Bool + ) throws(Failure) -> Bool + where OtherSequence: ~Copyable & ~Escapable, OtherSequence.Element: ~Copyable, OtherSequence.Failure == Failure { // FIXME: Forward to the iterator's implementation of same - var iter1 = makeBorrowingIterator_() - var iter2 = other.makeBorrowingIterator_() + var iter1 = makeBorrowingIterator() + var iter2 = other.makeBorrowingIterator() while true { - var el1 = try iter1.nextSpan_() + var el1 = try iter1.nextSpan() if el1.isEmpty { // LHS is empty - sequences are equal iff RHS is also empty - let el2 = try iter2.nextSpan_(maxCount: 1) + let el2 = try iter2.nextSpan(maxCount: 1) return el2.isEmpty } while el1.count > 0 { - let el2 = try iter2.nextSpan_(maxCount: el1.count) + let el2 = try iter2.nextSpan(maxCount: el1.count) if el2.isEmpty { return false } for i in 0..>( + public func elementsEqual>( _ other: borrowing OtherSequence - ) throws(Failure_) -> Bool + ) throws(Failure) -> Bool where OtherSequence: ~Copyable & ~Escapable, - OtherSequence.Element_: ~Copyable + OtherSequence.Element: ~Copyable { return try self.elementsEqual(other, by: ==) } diff --git a/Sources/ContainersPreview/Protocols/Iterable+Utilities.swift b/Sources/ContainersPreview/Protocols/Iterable+Utilities.swift index b1f4de7a..ae4c33b9 100644 --- a/Sources/ContainersPreview/Protocols/Iterable+Utilities.swift +++ b/Sources/ContainersPreview/Protocols/Iterable+Utilities.swift @@ -18,21 +18,21 @@ import InternalCollectionsUtilities #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) -extension Iterable_ where Self: ~Copyable & ~Escapable, Element_: Copyable { +extension Iterable where Self: ~Copyable & ~Escapable, Element: Copyable { @inlinable package func _copyContents( - intoPrefixOf buffer: UnsafeMutableBufferPointer - ) throws(Failure_) -> Int { + intoPrefixOf buffer: UnsafeMutableBufferPointer + ) throws(Failure) -> Int { var target = buffer - var it = self.makeBorrowingIterator_() + var it = self.makeBorrowingIterator() while target.count != 0 { - let span = try it.nextSpan_(maxCount: target.count) + let span = try it.nextSpan(maxCount: target.count) if span.isEmpty { return buffer.count - target.count } target._initializeAndDropPrefix(copying: span) } - let test = try it.nextSpan_() + let test = try it.nextSpan() precondition(test.isEmpty, "Contents do not fit in target buffer") return buffer.count } diff --git a/Sources/ContainersPreview/Protocols/Iterable.swift b/Sources/ContainersPreview/Protocols/Iterable.swift deleted file mode 100644 index e6c97554..00000000 --- a/Sources/ContainersPreview/Protocols/Iterable.swift +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2024 - 2026 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception -// -//===----------------------------------------------------------------------===// - -#if compiler(>=6.4) && UnstableContainersPreview - -@available(SwiftStdlib 6.4, *) -public protocol Iterable_: ~Copyable, ~Escapable { - // FIXME: None of these names should not have trailing underscores, but that - // would clash with the stdlib's versions: - // error: 'BorrowingIterator' is ambiguous for type lookup in this context - // - // This is likely best resolved by removing these definitions as soon as they - // appear in the stdlib. - associatedtype Element_: ~Copyable - associatedtype Failure_: Error = Never - - associatedtype BorrowingIterator_: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable - - var underestimatedCount_: Int { get } - - @_lifetime(borrow self) - borrowing func makeBorrowingIterator_() -> BorrowingIterator_ - - func _customContainsEquatableElement_( - _ element: borrowing Element_ - ) -> Bool? -} - -@available(SwiftStdlib 6.4, *) -extension Iterable_ -where - Self: ~Copyable & ~Escapable, Element_: ~Copyable -{ - @inlinable - public var underestimatedCount_: Int { 0 } - - @inlinable - public func _customContainsEquatableElement_(_ element: borrowing Element_) -> Bool? { - nil - } -} - -@available(SwiftStdlib 6.4, *) -extension Iterable_ where Self: Sequence { - @inlinable - public var underestimatedCount_: Int { 0 } - - @inlinable - public func _customContainsEquatableElement_(_ element: borrowing Element) -> Bool? { - nil - } -} - -#endif diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Append.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Append.swift index 98193fac..9b4dfef3 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Append.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Append.swift @@ -314,12 +314,12 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient internal mutating func _append< - S: Iterable_ & ~Copyable & ~Escapable - >(copying items: borrowing S) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() + S: Iterable & ~Copyable & ~Escapable + >(copying items: borrowing S) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() if span.isEmpty { break } self.append(copying: span) } @@ -337,10 +337,10 @@ extension RigidDeque /*where Element: Copyable*/ { /// - Complexity: O(*m*), where *m* is the length of `newElements`. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func append( + public mutating func append( copying newElements: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._append(copying: newElements) } #endif @@ -380,11 +380,11 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient public mutating func append< - S: Iterable_ & Sequence + S: Iterable & Sequence >( copying items: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._append(copying: items) } #endif diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Container.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Container.swift index 3cf99daa..e5bbc278 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Container.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Container.swift @@ -23,9 +23,7 @@ import ContainersPreview extension RigidDeque where Element: ~Copyable { #if compiler(>=6.4) && UnstableContainersPreview @frozen - public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol_ { - public typealias Element_ = Element - + public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol { @usableFromInline internal var _currentSegment: Span @@ -73,7 +71,7 @@ extension RigidDeque where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(&self) @_lifetime(self: copy self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { let result = _currentSegment._trim(first: maxCount) if _currentSegment.isEmpty { _currentSegment = _nextSegment @@ -86,7 +84,7 @@ extension RigidDeque where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(borrow self) - public borrowing func makeBorrowingIterator_() -> BorrowingIterator { + public borrowing func makeBorrowingIterator() -> BorrowingIterator { BorrowingIterator(_deque: self) } #endif @@ -99,12 +97,12 @@ extension RigidDeque: Container where Element: ~Copyable { @_lifetime(borrow self) public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { BorrowingIterator(_deque: self, from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { // FIXME: This should validate that the iterator belongs to this deque. return iterator._position } diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Initializers.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Initializers.swift index f5f8bb00..ecccba24 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Initializers.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Initializers.swift @@ -132,11 +132,11 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init( + public init( capacity: Int, copying contents: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity) try self._append(copying: contents) } @@ -187,11 +187,11 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int, copying contents: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity) try self._append(copying: contents) } @@ -210,11 +210,11 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int? = nil, copying contents: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(capacity: capacity ?? contents.count) try self._append(copying: contents) } diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Insertions.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Insertions.swift index d3c2f951..83610e24 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Insertions.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Insertions.swift @@ -366,12 +366,12 @@ extension RigidDeque /* where Element: Copyable */ { newCount: Int ) { let expectedCount = self.count + newCount - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() insert(addingCount: newCount, at: index) { target in - it._copyContents_(into: &target) + it._copyContents(into: &target) } precondition( - it.nextSpan_().isEmpty && self.count == expectedCount, + it.nextSpan().isEmpty && self.count == expectedCount, "Broken Container: count doesn't match contents") } #endif diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Prepend.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Prepend.swift index 7ed7e432..97da2b5b 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Prepend.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Prepend.swift @@ -291,16 +291,16 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @inlinable internal mutating func _prepend< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { // We don't know the exact count of new elements, so we cannot initialize // them in place. Append them to the end of the deque first, then rotate // them to their correct location. // - // FIXME: If we get a Iterable_.estimatedCount with an exact case, + // FIXME: If we get a Iterable.estimatedCount with an exact case, // then we should use that when possible to copy items to their final // location in a single pass. let oldCount = self.count @@ -311,15 +311,15 @@ extension RigidDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @inlinable internal mutating func _prepend< - S: Iterable_ & ~Copyable & ~Escapable + S: Iterable & ~Copyable & ~Escapable >( copying items: borrowing S, exactCount: Int - ) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() - try self.prepend(addingCount: exactCount) { (target) throws(S.Failure_) in - let span = try it.nextSpan_(maxCount: target.freeCapacity) + ) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() + try self.prepend(addingCount: exactCount) { (target) throws(S.Failure) in + let span = try it.nextSpan(maxCount: target.freeCapacity) target._append(copying: span) } } @@ -340,10 +340,10 @@ extension RigidDeque /*where Element: Copyable*/ { /// - Complexity: O(*m*), where *m* is the length of `items`. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend( + public mutating func prepend( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items) } @@ -447,10 +447,10 @@ extension RigidDeque /*where Element: Copyable*/ { /// - Complexity: O(*m*), where *m* is the length of `items`. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend>( + public mutating func prepend>( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items) } @@ -465,10 +465,10 @@ extension RigidDeque /*where Element: Copyable*/ { /// - Complexity: O(*m*), where *m* is the length of `items`. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend>( + public mutating func prepend>( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items, exactCount: items.count) } diff --git a/Sources/DequeModule/RigidDeque/RigidDeque+Replacements.swift b/Sources/DequeModule/RigidDeque/RigidDeque+Replacements.swift index 1e44dcb2..1199cb83 100644 --- a/Sources/DequeModule/RigidDeque/RigidDeque+Replacements.swift +++ b/Sources/DequeModule/RigidDeque/RigidDeque+Replacements.swift @@ -467,12 +467,12 @@ extension RigidDeque /* where Element: Copyable */ { ) { let expectedCount = self.count - subrange.count + newCount - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() self.replace(removing: subrange, addingCount: newCount) { target in - it._copyContents_(into: &target) + it._copyContents(into: &target) } precondition( - it.nextSpan_().isEmpty && count == expectedCount, + it.nextSpan().isEmpty && count == expectedCount, "Broken Container: count doesn't match contents") } #endif diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Append.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Append.swift index d4a36811..b1df2780 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Append.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Append.swift @@ -300,13 +300,13 @@ extension UniqueDeque /*where Element: Copyable*/ { #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - internal mutating func _append( + internal mutating func _append( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() + ) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() if span.isEmpty { break } self.append(copying: span) } @@ -326,10 +326,10 @@ extension UniqueDeque /*where Element: Copyable*/ { /// over many similar invocations on the same deque @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func append( + public mutating func append( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._append(copying: items) } #endif @@ -378,10 +378,10 @@ extension UniqueDeque /*where Element: Copyable*/ { /// amortized over many similar invocations over the same deque. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func append>( + public mutating func append>( copying items: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._append(copying: items) } #endif diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Container.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Container.swift index dfa485a2..c02a2f67 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Container.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Container.swift @@ -26,7 +26,7 @@ extension UniqueDeque where Element: ~Copyable { @_alwaysEmitIntoClient @_lifetime(borrow self) - public borrowing func makeBorrowingIterator_() -> BorrowingIterator { + public borrowing func makeBorrowingIterator() -> BorrowingIterator { BorrowingIterator(_deque: self._storage) } #endif @@ -39,13 +39,13 @@ extension UniqueDeque: Container where Element: ~Copyable { @_lifetime(borrow self) public func makeBorrowingIterator( from start: Index, to end: Index - ) -> BorrowingIterator_ { + ) -> BorrowingIterator { _storage.makeBorrowingIterator(from: start, to: end) } @_alwaysEmitIntoClient - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { - _storage.currentIndex(of: iterator) + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { + _storage.currentIndex(of: &iterator) } } diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Initializers.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Initializers.swift index b1341a12..64723aff 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Initializers.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Initializers.swift @@ -145,11 +145,11 @@ extension UniqueDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init( + public init( capacity: Int? = nil, copying contents: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(minimumCapacity: capacity ?? 0) try self._append(copying: contents) } @@ -184,11 +184,11 @@ extension UniqueDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int? = nil, copying contents: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(minimumCapacity: capacity ?? contents.underestimatedCount) try self._append(copying: contents) } @@ -203,11 +203,11 @@ extension UniqueDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient @inline(__always) - public init>( + public init>( capacity: Int? = nil, copying contents: S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { self.init(minimumCapacity: capacity ?? contents.count) try self._append(copying: contents) } diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Insertions.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Insertions.swift index 813ddf21..086fd191 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Insertions.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Insertions.swift @@ -384,12 +384,12 @@ extension UniqueDeque /* where Element: Copyable */ { newCount: Int ) { let expectedCount = self.count + newCount - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() insert(addingCount: newCount, at: index) { target in - it._copyContents_(into: &target) + it._copyContents(into: &target) } precondition( - it.nextSpan_().isEmpty && count == expectedCount, + it.nextSpan().isEmpty && count == expectedCount, "Broken Container: count doesn't match contents") } #endif diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Prepend.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Prepend.swift index 45e5da0a..ae0dd9bb 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Prepend.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Prepend.swift @@ -322,10 +322,10 @@ extension UniqueDeque /*where Element: Copyable*/ { #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) @inlinable - internal mutating func _prepend( + internal mutating func _prepend( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element + ) throws(S.Failure) + where S.Element == Element { // We don't know the exact count of new elements, so we cannot initialize // them in place. Append them to the end of the deque first, then rotate @@ -341,14 +341,14 @@ extension UniqueDeque /*where Element: Copyable*/ { @available(SwiftStdlib 6.4, *) @inlinable - internal mutating func _prepend( + internal mutating func _prepend( copying items: borrowing S, exactCount: Int - ) throws(S.Failure_) - where S.Element_ == Element { - var it = items.makeBorrowingIterator_() - try self.prepend(addingCount: exactCount) { (target) throws(S.Failure_) in - let span = try it.nextSpan_(maxCount: target.freeCapacity) + ) throws(S.Failure) + where S.Element == Element { + var it = items.makeBorrowingIterator() + try self.prepend(addingCount: exactCount) { (target) throws(S.Failure) in + let span = try it.nextSpan(maxCount: target.freeCapacity) target._append(copying: span) } } @@ -370,10 +370,10 @@ extension UniqueDeque /*where Element: Copyable*/ { /// over many similar invocations on the same deque. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend( + public mutating func prepend( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items) } @@ -483,10 +483,10 @@ extension UniqueDeque /*where Element: Copyable*/ { /// over many similar invocations on the same deque. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend>( + public mutating func prepend>( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items) } @@ -502,10 +502,10 @@ extension UniqueDeque /*where Element: Copyable*/ { /// over many similar invocations on the same deque. @available(SwiftStdlib 6.4, *) @_alwaysEmitIntoClient - public mutating func prepend>( + public mutating func prepend>( copying items: borrowing S - ) throws(S.Failure_) - where S.Element_ == Element { + ) throws(S.Failure) + where S.Element == Element { try self._prepend(copying: items, exactCount: items.count) } diff --git a/Sources/DequeModule/UniqueDeque/UniqueDeque+Replacements.swift b/Sources/DequeModule/UniqueDeque/UniqueDeque+Replacements.swift index ca0579ad..3759b9d6 100644 --- a/Sources/DequeModule/UniqueDeque/UniqueDeque+Replacements.swift +++ b/Sources/DequeModule/UniqueDeque/UniqueDeque+Replacements.swift @@ -476,12 +476,12 @@ extension UniqueDeque /* where Element: Copyable */ { ) { let expectedCount = self.count - subrange.count + newCount - var it = items.makeBorrowingIterator_() + var it = items.makeBorrowingIterator() self.replace(removing: subrange, addingCount: newCount) { target in - it._copyContents_(into: &target) + it._copyContents(into: &target) } precondition( - it.nextSpan_().isEmpty && count == expectedCount, + it.nextSpan().isEmpty && count == expectedCount, "Broken Container: count doesn't match contents") } #endif diff --git a/Tests/BasicContainersTests/RigidArrayTests.swift b/Tests/BasicContainersTests/RigidArrayTests.swift index f6ede667..c63450d6 100644 --- a/Tests/BasicContainersTests/RigidArrayTests.swift +++ b/Tests/BasicContainersTests/RigidArrayTests.swift @@ -1483,7 +1483,7 @@ class RigidArrayTests: CollectionTestCase { func test_borrowing_map() { let c = 100 let items = RigidArray(capacity: c, copying: 0 ..< c) - let transformed = items.makeBorrowingIterator_() + let transformed = items.makeBorrowingIterator() .map { 2 * $0 } .collect(into: UniqueArray.self) expectEqual(transformed.count, c) @@ -1497,7 +1497,7 @@ class RigidArrayTests: CollectionTestCase { func test_borrowing_filter() { let c = 100 let items = RigidArray(capacity: c, copying: 0 ..< c) - let transformed = items.makeBorrowingIterator_() + let transformed = items.makeBorrowingIterator() .filter { !$0.isMultiple(of: 6) } .copy() .collect(into: UniqueArray.self) diff --git a/Tests/BasicContainersTests/RigidDictionaryTests.swift b/Tests/BasicContainersTests/RigidDictionaryTests.swift index 13fc9f4b..936882e0 100644 --- a/Tests/BasicContainersTests/RigidDictionaryTests.swift +++ b/Tests/BasicContainersTests/RigidDictionaryTests.swift @@ -259,9 +259,9 @@ class RigidDictionaryTests: CollectionTestCase { #if UnstableContainersPreview var actual: Set = [] _with(d.keys) { keys in // FIXME: Sigh, borrow accessors are limited in 6.4 - var it = keys.makeBorrowingIterator_() + var it = keys.makeBorrowingIterator() while true { - let next = it.nextSpan_() + let next = it.nextSpan() guard !next.isEmpty else { break } for i in next.indices { expectTrue( @@ -297,10 +297,10 @@ class RigidDictionaryTests: CollectionTestCase { expectEqual(keys.count, i + 1) expectEqual(keys.capacity, capacity) #if UnstableContainersPreview - var it = keys.makeBorrowingIterator_() + var it = keys.makeBorrowingIterator() var actual: Set = [] while true { - let next = it.nextSpan_() + let next = it.nextSpan() guard !next.isEmpty else { break } for i in next.indices { expectTrue( @@ -362,9 +362,9 @@ class RigidDictionaryTests: CollectionTestCase { var seen: Set = [] let indices = d.indices - var it = indices.makeBorrowingIterator_() + var it = indices.makeBorrowingIterator() while true { - let next = it.nextSpan_() + let next = it.nextSpan() if next.isEmpty { break } expectEqual(next.count, 1) var i = 0 diff --git a/Tests/BasicContainersTests/RigidSetTests.swift b/Tests/BasicContainersTests/RigidSetTests.swift index bfc8bc44..d3016d45 100644 --- a/Tests/BasicContainersTests/RigidSetTests.swift +++ b/Tests/BasicContainersTests/RigidSetTests.swift @@ -301,9 +301,9 @@ class RigidSetTests: CollectionTestCase { s.insert(tracker.instance(for: i)) var expected = Set(0 ... i) - var it = s.makeBorrowingIterator_() + var it = s.makeBorrowingIterator() while true { - let next = it.nextSpan_(maxCount: maxCount) + let next = it.nextSpan(maxCount: maxCount) guard !next.isEmpty else { break } expectLessThanOrEqual(next.count, maxCount) for j in next.indices { diff --git a/Tests/BasicContainersTests/UniqueDictionaryTests.swift b/Tests/BasicContainersTests/UniqueDictionaryTests.swift index 5f8e188c..c42af770 100644 --- a/Tests/BasicContainersTests/UniqueDictionaryTests.swift +++ b/Tests/BasicContainersTests/UniqueDictionaryTests.swift @@ -147,9 +147,9 @@ class UniqueDictionaryTests: CollectionTestCase { #if UnstableContainersPreview var actual: Set = [] _with(d.keys) { keys in // FIXME: Sigh, borrow accessors are limited in 6.4 - var it = keys.makeBorrowingIterator_() + var it = keys.makeBorrowingIterator() while true { - let next = it.nextSpan_() + let next = it.nextSpan() guard !next.isEmpty else { break } for i in next.indices { expectTrue( @@ -185,10 +185,10 @@ class UniqueDictionaryTests: CollectionTestCase { expectEqual(keys.count, i + 1) expectEqual(keys.capacity, capacity) #if UnstableContainersPreview - var it = keys.makeBorrowingIterator_() + var it = keys.makeBorrowingIterator() var actual: Set = [] while true { - let next = it.nextSpan_() + let next = it.nextSpan() guard !next.isEmpty else { break } for i in next.indices { expectTrue( @@ -249,9 +249,9 @@ class UniqueDictionaryTests: CollectionTestCase { var seen: Set = [] let indices = d.indices - var it = indices.makeBorrowingIterator_() + var it = indices.makeBorrowingIterator() while true { - let next = it.nextSpan_() + let next = it.nextSpan() if next.isEmpty { break } expectEqual(next.count, 1) var i = 0 diff --git a/Tests/ContainersTests/BorrowingSequenceTests.swift b/Tests/ContainersTests/BorrowingSequenceTests.swift index f89a48fa..0a26086a 100644 --- a/Tests/ContainersTests/BorrowingSequenceTests.swift +++ b/Tests/ContainersTests/BorrowingSequenceTests.swift @@ -64,12 +64,12 @@ final class IterableTests: XCTestCase { } @available(SwiftStdlib 6.4, *) -extension Iterable_ where Self: ~Copyable & ~Escapable, Element_: Copyable { - func collectViaBorrowing() throws(Failure_) -> [Element_] { - var borrowIterator = makeBorrowingIterator_() - var result: [Element_] = [] +extension Iterable where Self: ~Copyable & ~Escapable, Element: Copyable { + func collectViaBorrowing() throws(Failure) -> [Element] { + var borrowIterator = makeBorrowingIterator() + var result: [Element] = [] while true { - let span = try borrowIterator.nextSpan_(maxCount: .max) + let span = try borrowIterator.nextSpan(maxCount: .max) if span.isEmpty { break } for i in span.indices { result.append(span[i]) diff --git a/Tests/_CollectionsTestSupport/AssertionContexts/Assertions+Containers.swift b/Tests/_CollectionsTestSupport/AssertionContexts/Assertions+Containers.swift index 2a7522a5..e1bdbe5e 100644 --- a/Tests/_CollectionsTestSupport/AssertionContexts/Assertions+Containers.swift +++ b/Tests/_CollectionsTestSupport/AssertionContexts/Assertions+Containers.swift @@ -127,7 +127,7 @@ public func expectIterableContents< @available(SwiftStdlib 6.4, *) public func expectIterablePayloads< Payload: Equatable, - E1: Iterable_, E> & ~Copyable & ~Escapable, + E1: Iterable, E> & ~Copyable & ~Escapable, C2: Collection, E, >( @@ -137,12 +137,12 @@ public func expectIterablePayloads< trapping: Bool = false, file: StaticString = #filePath, line: UInt = #line -) throws(E) where E1.Element_: ~Copyable { - var it1 = left.makeBorrowingIterator_() +) throws(E) where E1.Element: ~Copyable { + var it1 = left.makeBorrowingIterator() var it2 = right.makeIterator() var i = 0 while true { - let next1 = try it1.nextSpan_(maxCount: 1) + let next1 = try it1.nextSpan(maxCount: 1) let next2 = it2.next() switch (next1.isEmpty, next2) { case (true, nil): @@ -175,7 +175,7 @@ public func expectIterablePayloads< @available(SwiftStdlib 6.4, *) public func expectIterablePayloads< Payload: Equatable, - E1: Iterable_, E> & ~Copyable & ~Escapable, + E1: Iterable, E> & ~Copyable & ~Escapable, C2: Collection, E, >( @@ -186,11 +186,11 @@ public func expectIterablePayloads< file: StaticString = #filePath, line: UInt = #line ) throws(E) { - var it1 = left.makeBorrowingIterator_() + var it1 = left.makeBorrowingIterator() var it2 = right.makeIterator() var i = 0 while true { - let next1 = try it1.nextSpan_(maxCount: 1) + let next1 = try it1.nextSpan(maxCount: 1) let next2 = it2.next() switch (next1.isEmpty, next2) { case (true, nil): @@ -222,21 +222,21 @@ public func expectIterablePayloads< #if compiler(>=6.4) && UnstableContainersPreview @available(SwiftStdlib 6.4, *) public func expectIterablesWithEquivalentElements< - S1: Iterable_ & ~Copyable & ~Escapable, - S2: Iterable_ & ~Copyable & ~Escapable + S1: Iterable & ~Copyable & ~Escapable, + S2: Iterable & ~Copyable & ~Escapable >( _ left: borrowing S1, _ right: borrowing S2, - by areEquivalent: (borrowing S1.Element_, borrowing S2.Element_) -> Bool, + by areEquivalent: (borrowing S1.Element, borrowing S2.Element) -> Bool, _ message: @autoclosure () -> String = "", trapping: Bool = false, file: StaticString = #filePath, line: UInt = #line -) throws(S1.Failure_) +) throws(S1.Failure) where - S1.Element_: ~Copyable, - S2.Element_: ~Copyable, - S1.Failure_ == S2.Failure_ + S1.Element: ~Copyable, + S2.Element: ~Copyable, + S1.Failure == S2.Failure { if try left._elementsEqual(right, by: areEquivalent) { return } _expectFailure( @@ -248,8 +248,8 @@ where @available(SwiftStdlib 6.4, *) public func expectIterablesWithEqualElements< Element: Equatable, - S1: Iterable_ & ~Copyable & ~Escapable, - S2: Iterable_ & ~Copyable & ~Escapable, + S1: Iterable & ~Copyable & ~Escapable, + S2: Iterable & ~Copyable & ~Escapable, E, >( _ left: borrowing S1, @@ -260,8 +260,8 @@ public func expectIterablesWithEqualElements< line: UInt = #line ) throws(E) where - S1.Element_: ~Copyable, - S2.Element_: ~Copyable + S1.Element: ~Copyable, + S2.Element: ~Copyable { if try left._elementsEqual(right) { return } _expectFailure( @@ -273,7 +273,7 @@ where @available(SwiftStdlib 6.4, *) public func expectIterableContents< Element: Equatable, - S1: Iterable_ & ~Copyable & ~Escapable, + S1: Iterable & ~Copyable & ~Escapable, C2: Collection, E, >( @@ -284,10 +284,10 @@ public func expectIterableContents< file: StaticString = #filePath, line: UInt = #line ) throws(E) { - var it1 = left.makeBorrowingIterator_() + var it1 = left.makeBorrowingIterator() var it2 = right.makeIterator() while true { - let span = try it1.nextSpan_() + let span = try it1.nextSpan() if span.isEmpty { break } for i in 0 ..< span.count { guard let b = it2.next() else { @@ -315,23 +315,23 @@ public func expectIterableContents< /// Check if `left` and `right` contain equal elements in the same order. @available(SwiftStdlib 6.4, *) public func expectIterableContents< - S1: Iterable_ & ~Copyable & ~Escapable, + S1: Iterable & ~Copyable & ~Escapable, C2: Collection, >( _ left: borrowing S1, equivalentTo right: C2, - by areEquivalent: (borrowing S1.Element_, C2.Element) -> Bool, - printer: (borrowing S1.Element_) -> String, + by areEquivalent: (borrowing S1.Element, C2.Element) -> Bool, + printer: (borrowing S1.Element) -> String, _ message: @autoclosure () -> String = "", trapping: Bool = false, file: StaticString = #filePath, line: UInt = #line -) throws(S1.Failure_) where S1.Element_: ~Copyable { - var it1 = left.makeBorrowingIterator_() +) throws(S1.Failure) where S1.Element: ~Copyable { + var it1 = left.makeBorrowingIterator() var it2 = right.makeIterator() var offset = 0 while true { - let span = try it1.nextSpan_() + let span = try it1.nextSpan() if span.isEmpty { break } for i in 0 ..< span.count { guard let b = it2.next() else { diff --git a/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift b/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift index 7f264011..c3755d46 100644 --- a/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift +++ b/Tests/_CollectionsTestSupport/ConformanceCheckers/CheckContainer.swift @@ -22,14 +22,14 @@ import ContainersPreview @available(SwiftStdlib 6.4, *) @inlinable public func checkIterable< - S: Iterable_ & ~Copyable & ~Escapable, - Expected: Sequence + S: Iterable & ~Copyable & ~Escapable, + Expected: Sequence >( _ iterable: borrowing S, expectedContents: Expected, file: StaticString = #filePath, line: UInt = #line -) throws(S.Failure_) where S.Element_: Equatable { +) throws(S.Failure) where S.Element: Equatable { try checkIterable( iterable, expectedContents: expectedContents, @@ -40,30 +40,30 @@ public func checkIterable< @available(SwiftStdlib 6.4, *) @inlinable public func checkIterable< - S: Iterable_ & ~Copyable & ~Escapable, - Expected: Sequence + S: Iterable & ~Copyable & ~Escapable, + Expected: Sequence >( _ iterable: borrowing S, expectedContents: Expected, - by areEquivalent: (S.Element_, S.Element_) -> Bool, + by areEquivalent: (S.Element, S.Element) -> Bool, file: StaticString = #filePath, line: UInt = #line -) throws(S.Failure_) where S.Element_: Equatable { +) throws(S.Failure) where S.Element: Equatable { let entry = TestContext.current.push("checkIterable", file: file, line: line) defer { TestContext.current.pop(entry) } let expectedContents = Array(expectedContents) - expectLessThanOrEqual(iterable.underestimatedCount_, expectedContents.count) + expectLessThanOrEqual(iterable.underestimatedCount, expectedContents.count) // Check that the spans seem plausibly sized and that the indices are monotonic. - let spanShapes: [Range] = try { () throws(S.Failure_) in + let spanShapes: [Range] = try { () throws(S.Failure) in var r: [Range] = [] var pos = 0 - var it = iterable.makeBorrowingIterator_() + var it = iterable.makeBorrowingIterator() while true { let origPos = pos - let span = try it.nextSpan_() + let span = try it.nextSpan() pos += span.count if span.isEmpty { break @@ -79,10 +79,10 @@ public func checkIterable< // Check that the spans have stable sizes and the expected contents. do { var pos = 0 - var it = iterable.makeBorrowingIterator_() + var it = iterable.makeBorrowingIterator() var spanIndex = 0 while true { - let span = try it.nextSpan_() + let span = try it.nextSpan() if span.isEmpty { break } expectEqual( span.count, spanShapes[spanIndex].count, @@ -100,9 +100,9 @@ public func checkIterable< // Check that we can iterate one by one. do { var pos = 0 - var it = iterable.makeBorrowingIterator_() + var it = iterable.makeBorrowingIterator() while true { - let span = try it.nextSpan_(maxCount: 1) + let span = try it.nextSpan(maxCount: 1) if span.isEmpty { break } expectEqual(span.count, 1) for i in 0 ..< span.count { @@ -116,10 +116,10 @@ public func checkIterable< // Check that we can iterate with huge maximum counts do { var pos = 0 - var it = iterable.makeBorrowingIterator_() + var it = iterable.makeBorrowingIterator() var spanIndex = 0 while true { - let span = try it.nextSpan_(maxCount: Int.max) + let span = try it.nextSpan(maxCount: Int.max) if span.isEmpty { break } expectEqual( span.count, spanShapes[spanIndex].count, diff --git a/Tests/_CollectionsTestSupport/MinimalTypes/StaccatoContainer.swift b/Tests/_CollectionsTestSupport/MinimalTypes/StaccatoContainer.swift index 243d7db2..1e07d78e 100644 --- a/Tests/_CollectionsTestSupport/MinimalTypes/StaccatoContainer.swift +++ b/Tests/_CollectionsTestSupport/MinimalTypes/StaccatoContainer.swift @@ -76,9 +76,7 @@ package struct _StaccatoParameters { } @available(SwiftStdlib 5.0, *) -public struct _StaccatoBorrowingIterator: BorrowingIteratorProtocol_, ~Escapable { - public typealias Element_ = Element - +public struct _StaccatoBorrowingIterator: BorrowingIteratorProtocol, ~Escapable { internal let _contents: Span internal let _params: _StaccatoParameters internal var _offset: Int @@ -99,7 +97,7 @@ public struct _StaccatoBorrowingIterator: BorrowingIteratorP } @_lifetime(&self) - public mutating func nextSpan_(maxCount: Int) -> Span { + public mutating func nextSpan(maxCount: Int) -> Span { precondition(maxCount > 0) let maxCount = Swift.min(maxCount, _end - _offset) let endOffset = _params.endOffset(fromOffset: _offset, maxCount: maxCount) @@ -134,13 +132,13 @@ public struct _StaccatoIndex: Comparable, Hashable{ } @available(SwiftStdlib 5.0, *) -extension StaccatoContainer: Iterable_ where Element: ~Copyable { - public typealias BorrowingIterator_ = _StaccatoBorrowingIterator // FIXME rdar://150240032 +extension StaccatoContainer: Iterable where Element: ~Copyable { + public typealias BorrowingIterator = _StaccatoBorrowingIterator // FIXME rdar://150240032 - public var underestimatedCount_: Int { count } + public var underestimatedCount: Int { count } - public func makeBorrowingIterator_() -> BorrowingIterator_ { - BorrowingIterator_(contents: _contents.span, params: _params) + public func makeBorrowingIterator() -> BorrowingIterator { + BorrowingIterator(contents: _contents.span, params: _params) } } @@ -152,11 +150,11 @@ extension StaccatoContainer: Container where Element: ~Copyable { public var count: Int { _params._count } @_lifetime(borrow self) - public func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator_ { - BorrowingIterator_(contents: _contents.span, params: _params, start: start, end: end) + public func makeBorrowingIterator(from start: Index, to end: Index) -> BorrowingIterator { + BorrowingIterator(contents: _contents.span, params: _params, start: start, end: end) } - public func currentIndex(of iterator: borrowing BorrowingIterator_) -> Index { + public func currentIndex(of iterator: inout BorrowingIterator) -> Index { iterator.currentIndex } diff --git a/Xcode/Collections.xcodeproj/project.pbxproj b/Xcode/Collections.xcodeproj/project.pbxproj index 6712ff1a..cf51dca0 100644 --- a/Xcode/Collections.xcodeproj/project.pbxproj +++ b/Xcode/Collections.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 7D0DC7BF2FFD929900BEE8B2 /* Array+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D0DC7BE2FFD929500BEE8B2 /* Array+Iterable.swift */; }; - 7D0DC7C12FFD92BB00BEE8B2 /* InlineArray+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D0DC7C02FFD92B500BEE8B2 /* InlineArray+Iterable.swift */; }; 7D0DC7C32FFD987800BEE8B2 /* Range+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D0DC7C22FFD987400BEE8B2 /* Range+Iterable.swift */; }; 7D0DC7C52FFD990E00BEE8B2 /* ClosedRange+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D0DC7C42FFD990E00BEE8B2 /* ClosedRange+Iterable.swift */; }; 7D0DC7C72FFDC40900BEE8B2 /* With.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D0DC7C62FFDC40600BEE8B2 /* With.swift */; }; @@ -163,9 +162,6 @@ 7D77E6252FD0F880003FA63B /* UnsafePointer+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D77E6242FD0F87B003FA63B /* UnsafePointer+Extras.swift */; }; 7D77E6272FD0F94B003FA63B /* UnsafeMutablePointer+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D77E6262FD0F940003FA63B /* UnsafeMutablePointer+Extras.swift */; }; 7D945E6B2FF5E0D1001041A6 /* UniqueSet+Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945E6A2FF5E0CB001041A6 /* UniqueSet+Deprecations.swift */; }; - 7D945E6D2FF71D76001041A6 /* Span+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945E6C2FF71D76001041A6 /* Span+Iterable.swift */; }; - 7D945E6F2FF71DFF001041A6 /* MutableSpan+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945E6E2FF71DF8001041A6 /* MutableSpan+Iterable.swift */; }; - 7D945E712FF71E58001041A6 /* OutputSpan+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945E702FF71E53001041A6 /* OutputSpan+Iterable.swift */; }; 7D945E732FF71E8C001041A6 /* InputSpan+Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D945E722FF71E86001041A6 /* InputSpan+Iterable.swift */; }; 7D9748D42E9748930098631A /* BigString+Chunk+UTF16.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9748D32E9748930098631A /* BigString+Chunk+UTF16.swift */; }; 7D9748D52E9748930098631A /* BigString+Chunk+UnicodeScalar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9748D12E9748930098631A /* BigString+Chunk+UnicodeScalar.swift */; }; @@ -221,7 +217,6 @@ 7DC037BA2FE3492D00CF0CB8 /* BorrowingIteratorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037B02FE3492D00CF0CB8 /* BorrowingIteratorProtocol.swift */; }; 7DC037BB2FE3492D00CF0CB8 /* Iterable+Algorithms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037AD2FE3492D00CF0CB8 /* Iterable+Algorithms.swift */; }; 7DC037BC2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Filter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037B32FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Filter.swift */; }; - 7DC037BD2FE3492D00CF0CB8 /* Iterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037AC2FE3492D00CF0CB8 /* Iterable.swift */; }; 7DC037BE2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+ElementsEqual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037B22FE3492D00CF0CB8 /* BorrowingIteratorProtocol+ElementsEqual.swift */; }; 7DC037BF2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Reduce.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037B52FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Reduce.swift */; }; 7DC037C02FE3492D00CF0CB8 /* BorrowingIteratorProtocol+SpanwiseZip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DC037B62FE3492D00CF0CB8 /* BorrowingIteratorProtocol+SpanwiseZip.swift */; }; @@ -628,7 +623,6 @@ /* Begin PBXFileReference section */ 7D0DC7BE2FFD929500BEE8B2 /* Array+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Iterable.swift"; sourceTree = ""; }; - 7D0DC7C02FFD92B500BEE8B2 /* InlineArray+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InlineArray+Iterable.swift"; sourceTree = ""; }; 7D0DC7C22FFD987400BEE8B2 /* Range+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Range+Iterable.swift"; sourceTree = ""; }; 7D0DC7C42FFD990E00BEE8B2 /* ClosedRange+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ClosedRange+Iterable.swift"; sourceTree = ""; }; 7D0DC7C62FFDC40600BEE8B2 /* With.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = With.swift; sourceTree = ""; }; @@ -797,9 +791,6 @@ 7D77E6242FD0F87B003FA63B /* UnsafePointer+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UnsafePointer+Extras.swift"; sourceTree = ""; }; 7D77E6262FD0F940003FA63B /* UnsafeMutablePointer+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UnsafeMutablePointer+Extras.swift"; sourceTree = ""; }; 7D945E6A2FF5E0CB001041A6 /* UniqueSet+Deprecations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueSet+Deprecations.swift"; sourceTree = ""; }; - 7D945E6C2FF71D76001041A6 /* Span+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Span+Iterable.swift"; sourceTree = ""; }; - 7D945E6E2FF71DF8001041A6 /* MutableSpan+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MutableSpan+Iterable.swift"; sourceTree = ""; }; - 7D945E702FF71E53001041A6 /* OutputSpan+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OutputSpan+Iterable.swift"; sourceTree = ""; }; 7D945E722FF71E86001041A6 /* InputSpan+Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InputSpan+Iterable.swift"; sourceTree = ""; }; 7D9748CF2E9748930098631A /* BigString+Chunk+Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BigString+Chunk+Character.swift"; sourceTree = ""; }; 7D9748D02E9748930098631A /* BigString+Chunk+Index.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BigString+Chunk+Index.swift"; sourceTree = ""; }; @@ -851,7 +842,6 @@ 7DAD89AF2E8B09EC00DD5786 /* UnsafeRawBufferPointer+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UnsafeRawBufferPointer+Extras.swift"; sourceTree = ""; }; 7DB257A02F58B1A3007B539F /* RigidDictionary+Debugging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RigidDictionary+Debugging.swift"; sourceTree = ""; }; 7DB257A22F58B1CC007B539F /* UniqueDictionary+Debugging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueDictionary+Debugging.swift"; sourceTree = ""; }; - 7DC037AC2FE3492D00CF0CB8 /* Iterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Iterable.swift; sourceTree = ""; }; 7DC037AD2FE3492D00CF0CB8 /* Iterable+Algorithms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Iterable+Algorithms.swift"; sourceTree = ""; }; 7DC037AF2FE3492D00CF0CB8 /* Iterable+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Iterable+Utilities.swift"; sourceTree = ""; }; 7DC037B02FE3492D00CF0CB8 /* BorrowingIteratorProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BorrowingIteratorProtocol.swift; sourceTree = ""; }; @@ -1345,7 +1335,6 @@ 7D2A77312F27F1E4005780C7 /* Protocols */ = { isa = PBXGroup; children = ( - 7DC037AC2FE3492D00CF0CB8 /* Iterable.swift */, 7DC037AD2FE3492D00CF0CB8 /* Iterable+Algorithms.swift */, 7DC037AF2FE3492D00CF0CB8 /* Iterable+Utilities.swift */, 7DC037B02FE3492D00CF0CB8 /* BorrowingIteratorProtocol.swift */, @@ -1533,15 +1522,11 @@ children = ( 7D0DC7BE2FFD929500BEE8B2 /* Array+Iterable.swift */, 7D0DC7C42FFD990E00BEE8B2 /* ClosedRange+Iterable.swift */, - 7D0DC7C02FFD92B500BEE8B2 /* InlineArray+Iterable.swift */, 7D945E722FF71E86001041A6 /* InputSpan+Iterable.swift */, 7D59D0612FE49C87005B5097 /* InputSpan+Container.swift */, - 7D945E6E2FF71DF8001041A6 /* MutableSpan+Iterable.swift */, 7D59D0622FE49C87005B5097 /* MutableSpan+Container.swift */, - 7D945E702FF71E53001041A6 /* OutputSpan+Iterable.swift */, 7D59D0632FE49C87005B5097 /* OutputSpan+Container.swift */, 7D0DC7C22FFD987400BEE8B2 /* Range+Iterable.swift */, - 7D945E6C2FF71D76001041A6 /* Span+Iterable.swift */, 7D59D0642FE49C87005B5097 /* Span+Container.swift */, ); path = Conformances; @@ -2704,7 +2689,6 @@ 7DC037BA2FE3492D00CF0CB8 /* BorrowingIteratorProtocol.swift in Sources */, 7DC037BB2FE3492D00CF0CB8 /* Iterable+Algorithms.swift in Sources */, 7DC037BC2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Filter.swift in Sources */, - 7DC037BD2FE3492D00CF0CB8 /* Iterable.swift in Sources */, 7DC037BE2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+ElementsEqual.swift in Sources */, 7DC037BF2FE3492D00CF0CB8 /* BorrowingIteratorProtocol+Reduce.swift in Sources */, 7DC037C02FE3492D00CF0CB8 /* BorrowingIteratorProtocol+SpanwiseZip.swift in Sources */, @@ -2720,7 +2704,6 @@ 7D2A777F2F27F2BF005780C7 /* RigidDeque+Container.swift in Sources */, 7D2A77802F27F2BF005780C7 /* Deque.swift in Sources */, 7D2A77812F27F2BF005780C7 /* UniqueDeque+Append.swift in Sources */, - 7D945E712FF71E58001041A6 /* OutputSpan+Iterable.swift in Sources */, 7D2A77822F27F2BF005780C7 /* UniqueDeque+Initializers.swift in Sources */, 7D2A77832F27F2BF005780C7 /* Deque+Equatable.swift in Sources */, 7D2A77842F27F2BF005780C7 /* UniqueDeque+Container.swift in Sources */, @@ -3105,7 +3088,6 @@ 7DE9201829CA70F3004483EB /* OrderedDictionary+Invariants.swift in Sources */, 7DE920CD29CA70F4004483EB /* BitSet+CustomDebugStringConvertible.swift in Sources */, 7DE9212529CA70F4004483EB /* TreeSet+SetAlgebra isStrictSubset.swift in Sources */, - 7D945E6F2FF71DFF001041A6 /* MutableSpan+Iterable.swift in Sources */, 7DE9209229CA70F4004483EB /* Rope+_Storage.swift in Sources */, 7DE9203929CA70F3004483EB /* OrderedSet+Partial RangeReplaceableCollection.swift in Sources */, 7DE9206329CA70F4004483EB /* BigString+Contents.swift in Sources */, @@ -3173,13 +3155,11 @@ 7D77E6122FCF810E003FA63B /* CountedProducer.swift in Sources */, 7DE920E829CA70F4004483EB /* BitArray+BitwiseOperations.swift in Sources */, 7DE9207829CA70F4004483EB /* BigString+Append.swift in Sources */, - 7D0DC7C12FFD92BB00BEE8B2 /* InlineArray+Iterable.swift in Sources */, 7DE9217F29CA70F4004483EB /* _HeapNode.swift in Sources */, 7D479CB92F46A6DB00A8CB59 /* RigidSet+Debugging.swift in Sources */, 7DE9202929CA70F3004483EB /* OrderedSet+Codable.swift in Sources */, 7DE9204829CA70F3004483EB /* _HashTable+CustomStringConvertible.swift in Sources */, 7D479CE52F47D74500A8CB59 /* RigidDictionary+Resizing.swift in Sources */, - 7D945E6D2FF71D76001041A6 /* Span+Iterable.swift in Sources */, 7DE9213029CA70F4004483EB /* TreeSet+SetAlgebra isSuperset.swift in Sources */, 7DE9217529CA70F4004483EB /* TreeDictionary+MapValues.swift in Sources */, 7DE9206C29CA70F4004483EB /* BigString+Chunk.swift in Sources */, diff --git a/Xcode/Shared.xcconfig b/Xcode/Shared.xcconfig index 51643e43..489d0962 100644 --- a/Xcode/Shared.xcconfig +++ b/Xcode/Shared.xcconfig @@ -22,6 +22,7 @@ OTHER_SWIFT_FLAGS = $(inherited) \ -enable-experimental-feature AddressableParameters \ -enable-experimental-feature AddressableTypes \ -enable-experimental-feature SuppressedAssociatedTypesWithDefaults \ + -enable-experimental-feature BorrowingSequence \ -enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.0: macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" \ -enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.1: macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" \ -enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.6: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" \