diff --git a/Sources/ContainersPreview/CMakeLists.txt b/Sources/ContainersPreview/CMakeLists.txt index 1ece4352..b8021098 100644 --- a/Sources/ContainersPreview/CMakeLists.txt +++ b/Sources/ContainersPreview/CMakeLists.txt @@ -25,12 +25,9 @@ else() endif() target_sources(${module_name} PRIVATE - "Conformances/Array+Iterable.swift" - "Conformances/ClosedRange+Iterable.swift" "Conformances/InputSpan+Container.swift" "Conformances/MutableSpan+Container.swift" "Conformances/OutputSpan+Container.swift" - "Conformances/Range+Iterable.swift" "Conformances/RigidArray+Container.swift" "Conformances/RigidDeque+Container.swift" "Conformances/RigidSet+Container.swift" diff --git a/Sources/ContainersPreview/Conformances/Array+Iterable.swift b/Sources/ContainersPreview/Conformances/Array+Iterable.swift deleted file mode 100644 index f7851176..00000000 --- a/Sources/ContainersPreview/Conformances/Array+Iterable.swift +++ /dev/null @@ -1,30 +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 Array: @retroactive Iterable { - 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/ClosedRange+Iterable.swift b/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift deleted file mode 100644 index f63c7f01..00000000 --- a/Sources/ContainersPreview/Conformances/ClosedRange+Iterable.swift +++ /dev/null @@ -1,69 +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.2, *) -extension ClosedRange: @retroactive Iterable -where Bound: Strideable, Bound.Stride: SignedInteger -{ - public typealias Element = Bound - - @frozen - public struct BorrowingIterator: BorrowingIteratorProtocol, ~Copyable { - @usableFromInline - internal var _current: InlineArray<1, Bound> - - @usableFromInline - internal var _last: Bound - - @usableFromInline - internal var _progress: Bool - - @inlinable - internal init(_ base: ClosedRange) { - self._current = .init(repeating: base.lowerBound) - self._last = base.upperBound - self._progress = false - } - @inlinable - @_lifetime(&self) - public mutating func nextSpan(maxCount: Int) -> Span { - if _progress { - _current[0] = _current[0].advanced(by: 1) - } - guard _current[0] <= _last else { - _progress = false - return .init() - } - _progress = true - return _current.span - } - } - - @inlinable - public var underestimatedCount: Int { - guard let distance = Int(exactly: lowerBound.distance(to: upperBound)) - else { return 0 } - let advanced = distance.addingReportingOverflow(1) - guard !advanced.overflow else { return 0 } - return advanced.partialValue - } - - @inlinable - public func makeBorrowingIterator() -> BorrowingIterator { - BorrowingIterator(self) - } -} - -#endif diff --git a/Sources/ContainersPreview/Conformances/Range+Iterable.swift b/Sources/ContainersPreview/Conformances/Range+Iterable.swift deleted file mode 100644 index 5da241fd..00000000 --- a/Sources/ContainersPreview/Conformances/Range+Iterable.swift +++ /dev/null @@ -1,68 +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 Range: @retroactive Iterable -where Bound: Strideable, Bound.Stride: SignedInteger -{ - public typealias Element = Bound - - @frozen - public struct BorrowingIterator: BorrowingIteratorProtocol, ~Copyable { - @usableFromInline - internal var _current: InlineArray<1, Bound> - - @usableFromInline - internal var _end: Bound - - @usableFromInline - internal var _progress: Bool - - @inlinable - internal init(_ base: Range) { - self._current = .init(repeating: base.lowerBound) - self._end = base.upperBound - self._progress = false - } - @inlinable - @_lifetime(&self) - public mutating func nextSpan(maxCount: Int) -> Span { - if _progress { - _current[0] = _current[0].advanced(by: 1) - } - guard _current[0] < _end else { - _progress = false - return .init() - } - _progress = true - return _current.span - } - } - - @inlinable - public var underestimatedCount: Int { - guard let count = Int(exactly: lowerBound.distance(to: upperBound)) else { - return 0 - } - return count - } - - @inlinable - public func makeBorrowingIterator() -> BorrowingIterator { - BorrowingIterator(self) - } -} - -#endif