mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
Renaming BorrowingSequence_ to Iterable_
This commit is contained in:
1 parent
232e6aeacf
commit
4bda43f4a9
53 files changed
+197
-197
No files matched your search
@@ -349,7 +349,7 @@ extension RigidArray {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _append<
|
||||
Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
Source: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) {
|
||||
@@ -371,7 +371,7 @@ extension RigidArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
Source: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) {
|
||||
@@ -413,7 +413,7 @@ extension RigidArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: BorrowingSequence_<Element> & Sequence<Element>
|
||||
Source: Iterable_<Element> & Sequence<Element>
|
||||
>(copying newElements: Source) {
|
||||
_append(copying: newElements)
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ import ContainersPreview
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension RigidArray: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension RigidArray: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
SpanIterator(self.span)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ extension RigidArray /*where Element: Copyable*/ {
|
||||
/// The container must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
public init<Source: Iterable_<Element> & ~Copyable & ~Escapable>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing Source
|
||||
) {
|
||||
@@ -145,7 +145,7 @@ extension RigidArray /*where Element: Copyable*/ {
|
||||
/// The container must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: BorrowingSequence_<Element> & Sequence<Element>>(
|
||||
public init<Source: Iterable_<Element> & Sequence<Element>>(
|
||||
capacity: Int,
|
||||
copying contents: Source
|
||||
) {
|
||||
|
||||
@@ -415,7 +415,7 @@ extension RigidArray {
|
||||
copying items: borrowing C,
|
||||
newCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
insert(addingCount: newCount, at: index) { target in
|
||||
while !target.isFull {
|
||||
let source = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
|
||||
@@ -591,7 +591,7 @@ extension RigidArray {
|
||||
copyingContainer items: borrowing C,
|
||||
newCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
self.replace(removing: subrange, addingCount: newCount) { target in
|
||||
while !target.isFull {
|
||||
let source = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
|
||||
@@ -41,14 +41,14 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension RigidDictionary.Indices: BorrowingSequence_
|
||||
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 IterableIterator_: ~Escapable {
|
||||
public typealias Element = RigidDictionary.Index
|
||||
|
||||
@usableFromInline
|
||||
@@ -71,16 +71,16 @@ where Key: ~Copyable, Value: ~Copyable
|
||||
public var underestimatedCount_: Int { self._base.value.count }
|
||||
|
||||
@_lifetime(borrow self) // FIXME: Should be @_lifetime(copy self)
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
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 IterableIterator_(_it: override)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension RigidDictionary.Indices.BorrowingIterator_: BorrowingIteratorProtocol_
|
||||
extension RigidDictionary.Indices.IterableIterator_: IterableIteratorProtocol_
|
||||
where Key: ~Copyable, Value: ~Copyable {
|
||||
public typealias Element_ = Element
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import ContainersPreview
|
||||
#if compiler(>=6.4) && UnstableHashedContainers && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension RigidSet: BorrowingSequence_ where Element: ~Copyable {
|
||||
extension RigidSet: Iterable_ where Element: ~Copyable {
|
||||
public typealias Element_ = Element
|
||||
|
||||
@inlinable
|
||||
@@ -33,13 +33,13 @@ extension RigidSet: BorrowingSequence_ where Element: ~Copyable {
|
||||
|
||||
@inlinable
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(_set: self)
|
||||
public borrowing func makeIterableIterator_() -> IterableIterator_ {
|
||||
IterableIterator_(_set: self)
|
||||
}
|
||||
|
||||
@frozen
|
||||
public struct BorrowingIterator_:
|
||||
BorrowingIteratorProtocol_,
|
||||
public struct IterableIterator_:
|
||||
IterableIteratorProtocol_,
|
||||
~Copyable,
|
||||
~Escapable
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ extension RigidSet {
|
||||
|
||||
guard left.count == right.count else { return false }
|
||||
|
||||
var lit = left.makeBorrowingIterator_()
|
||||
var lit = left.makeIterableIterator_()
|
||||
while true {
|
||||
let l = lit.nextSpan_()
|
||||
if l.isEmpty { break }
|
||||
|
||||
@@ -37,7 +37,7 @@ extension RigidSet {
|
||||
public func _rawHashValue(seed: Int) -> Int {
|
||||
#if UnstableContainersPreview
|
||||
var hash = 0
|
||||
var it = self.makeBorrowingIterator_()
|
||||
var it = self.makeIterableIterator_()
|
||||
while true {
|
||||
let next = it.nextSpan_()
|
||||
var i = 0
|
||||
|
||||
@@ -85,7 +85,7 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -119,7 +119,7 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -131,7 +131,7 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
S: Iterable_<Element> & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
|
||||
@@ -223,11 +223,11 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
package mutating func _insert<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
guard !span.isEmpty else { break }
|
||||
@@ -240,7 +240,7 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -261,7 +261,7 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
|
||||
@@ -310,12 +310,12 @@ extension UniqueArray {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _append<
|
||||
Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
Source: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) {
|
||||
_ensureFreeCapacity(newElements.underestimatedCount_)
|
||||
var it = newElements.makeBorrowingIterator_()
|
||||
var it = newElements.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
@@ -343,7 +343,7 @@ extension UniqueArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
Source: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) {
|
||||
@@ -397,7 +397,7 @@ extension UniqueArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: BorrowingSequence_<Element> & Sequence<Element>
|
||||
Source: Iterable_<Element> & Sequence<Element>
|
||||
>(copying newElements: Source) {
|
||||
self._append(copying: newElements)
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ import ContainersPreview
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueArray: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = RigidArray<Element>.BorrowingIterator_
|
||||
extension UniqueArray: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = RigidArray<Element>.IterableIterator_
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
self._storage.makeBorrowingIterator_()
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
self._storage.makeIterableIterator_()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -96,7 +96,7 @@ extension UniqueArray /*where Element: Copyable*/ {
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
public init<Source: Iterable_<Element> & ~Copyable & ~Escapable>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: borrowing Source
|
||||
) {
|
||||
@@ -132,7 +132,7 @@ extension UniqueArray /*where Element: Copyable*/ {
|
||||
/// - contents: The container whose contents to copy into the new array.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: BorrowingSequence_<Element> & Sequence<Element>>(
|
||||
public init<Source: Iterable_<Element> & Sequence<Element>>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: Source
|
||||
) {
|
||||
|
||||
@@ -19,9 +19,9 @@ import ContainersPreview
|
||||
#if compiler(>=6.4) && UnstableHashedContainers && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueSet: BorrowingSequence_ where Element: ~Copyable {
|
||||
extension UniqueSet: Iterable_ where Element: ~Copyable {
|
||||
public typealias Element_ = Element
|
||||
public typealias BorrowingIterator_ = RigidSet<Element>.BorrowingIterator_
|
||||
public typealias IterableIterator_ = RigidSet<Element>.IterableIterator_
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
@@ -35,8 +35,8 @@ extension UniqueSet: BorrowingSequence_ where Element: ~Copyable {
|
||||
|
||||
@inlinable
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(_set: _storage)
|
||||
public borrowing func makeIterableIterator_() -> IterableIterator_ {
|
||||
IterableIterator_(_set: _storage)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -77,7 +77,7 @@ extension UniqueSet where Element: Copyable {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -95,7 +95,7 @@ extension UniqueSet where Element: Copyable {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
|
||||
@@ -132,12 +132,12 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
package mutating func _insert<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
_ensureFreeCapacity(items.underestimatedCount_)
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
guard !span.isEmpty else { break }
|
||||
@@ -150,7 +150,7 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -172,7 +172,7 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
|
||||
@@ -86,7 +86,7 @@ where Base.Element: ~Copyable
|
||||
// FIXME: Sendable
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension ContainerFilter: BorrowingIteratorProtocol_ where Element: ~Copyable {
|
||||
extension ContainerFilter: IterableIteratorProtocol_ where Element: ~Copyable {
|
||||
public typealias Element_ = Base.Element
|
||||
|
||||
@_lifetime(&self) // FIXME: This should be `@_lifetime(copy self)`
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public protocol Container<Element>:
|
||||
BorrowingSequence_, ~Copyable, ~Escapable
|
||||
Iterable_, ~Copyable, ~Escapable
|
||||
where Element: ~Copyable, Element == Element_
|
||||
{
|
||||
associatedtype Element: ~Copyable
|
||||
|
||||
@@ -18,10 +18,10 @@ extension Container
|
||||
where
|
||||
Self: ~Copyable /*FIXME: & ~Escapable*/,
|
||||
Element: ~Copyable,
|
||||
BorrowingIterator_ == ContainerIterator<Self>
|
||||
IterableIterator_ == ContainerIterator<Self>
|
||||
{
|
||||
@_lifetime(borrow self)
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
ContainerIterator(_borrowing: self, from: self.startIndex)
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ where Base.Element: ~Copyable
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension ContainerIterator: BorrowingIteratorProtocol_
|
||||
extension ContainerIterator: IterableIteratorProtocol_
|
||||
where
|
||||
Base: ~Copyable /*FIXME: & ~Escapable*/,
|
||||
Base.Element: ~Copyable
|
||||
|
||||
@@ -427,11 +427,11 @@ where
|
||||
|
||||
@inlinable
|
||||
public mutating func append<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
guard !span.isEmpty else { break }
|
||||
|
||||
+12
-12
@@ -14,7 +14,7 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where Self: ~Copyable & ~Escapable, Element_: ~Copyable
|
||||
{
|
||||
@inlinable
|
||||
@@ -23,7 +23,7 @@ extension BorrowingSequence_
|
||||
_ nextPartialResult:
|
||||
(_ partialResult: consuming Result, borrowing Element_) throws -> Result
|
||||
) rethrows -> Result {
|
||||
try makeBorrowingIterator_().reduce(initialResult, nextPartialResult)
|
||||
try makeIterableIterator_().reduce(initialResult, nextPartialResult)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@@ -32,19 +32,19 @@ extension BorrowingSequence_
|
||||
_ updateAccumulatingResult:
|
||||
(_ partialResult: inout Result, borrowing Element_) throws -> ()
|
||||
) rethrows -> Result {
|
||||
try makeBorrowingIterator_().reduce(into: initialResult, updateAccumulatingResult)
|
||||
try makeIterableIterator_().reduce(into: initialResult, updateAccumulatingResult)
|
||||
}
|
||||
}
|
||||
|
||||
// Ambiguity breakers
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension Sequence where Self: BorrowingSequence_ {
|
||||
extension Sequence where Self: Iterable_ {
|
||||
public func reduce<Result: ~Copyable>(
|
||||
_ initialResult: consuming Result,
|
||||
_ nextPartialResult:
|
||||
(_ partialResult: consuming Result, borrowing Element_) throws -> Result
|
||||
) rethrows -> Result {
|
||||
try makeBorrowingIterator_().reduce(initialResult, nextPartialResult)
|
||||
try makeIterableIterator_().reduce(initialResult, nextPartialResult)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@@ -53,24 +53,24 @@ extension Sequence where Self: BorrowingSequence_ {
|
||||
_ updateAccumulatingResult:
|
||||
(_ partialResult: inout Result, borrowing Element_) throws -> ()
|
||||
) rethrows -> Result {
|
||||
try makeBorrowingIterator_().reduce(into: initialResult, updateAccumulatingResult)
|
||||
try makeIterableIterator_().reduce(into: initialResult, updateAccumulatingResult)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where Self: ~Copyable & ~Escapable, Element_: ~Copyable
|
||||
{
|
||||
@inlinable
|
||||
public func elementsEqual<OtherSequence: BorrowingSequence_>(
|
||||
public func elementsEqual<OtherSequence: Iterable_>(
|
||||
_ other: borrowing OtherSequence,
|
||||
by areEquivalent: (borrowing Element_, borrowing OtherSequence.Element_) throws -> Bool
|
||||
) rethrows -> Bool
|
||||
where OtherSequence: ~Copyable & ~Escapable, OtherSequence.Element_: ~Copyable
|
||||
{
|
||||
// FIXME: Forward to the iterator's implementation of same
|
||||
var iter1 = makeBorrowingIterator_()
|
||||
var iter2 = other.makeBorrowingIterator_()
|
||||
var iter1 = makeIterableIterator_()
|
||||
var iter2 = other.makeIterableIterator_()
|
||||
while true {
|
||||
var el1 = iter1.nextSpan_()
|
||||
|
||||
@@ -93,10 +93,10 @@ extension BorrowingSequence_
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where Self: ~Copyable & ~Escapable, Element_: ~Copyable & Equatable {
|
||||
@inlinable
|
||||
public func elementsEqual<OtherSequence: BorrowingSequence_<Element_>>(
|
||||
public func elementsEqual<OtherSequence: Iterable_<Element_>>(
|
||||
_ other: borrowing OtherSequence
|
||||
) -> Bool
|
||||
where
|
||||
+26
-26
@@ -14,8 +14,8 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension Span: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension Span: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
public typealias Element_ = Element
|
||||
|
||||
@inlinable
|
||||
@@ -23,21 +23,21 @@ extension Span: BorrowingSequence_ where Element: ~Copyable {
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> SpanIterator<Element> {
|
||||
public func makeIterableIterator_() -> SpanIterator<Element> {
|
||||
SpanIterator(self)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension MutableSpan: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension MutableSpan: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> SpanIterator<Element> {
|
||||
public func makeIterableIterator_() -> SpanIterator<Element> {
|
||||
// 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
|
||||
@@ -47,57 +47,57 @@ extension MutableSpan: BorrowingSequence_ where Element: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension OutputSpan: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension OutputSpan: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
SpanIterator(self.span)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension InputSpan: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension InputSpan: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
SpanIterator(self.span)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension Array: BorrowingSequence_ {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension Array: Iterable_ {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
SpanIterator(self.span)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension InlineArray: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = SpanIterator<Element>
|
||||
extension InlineArray: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = SpanIterator<Element>
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> SpanIterator<Element> {
|
||||
public func makeIterableIterator_() -> SpanIterator<Element> {
|
||||
// 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
|
||||
@@ -107,13 +107,13 @@ extension InlineArray: BorrowingSequence_ where Element: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension Range: BorrowingSequence_
|
||||
extension Range: Iterable_
|
||||
where Bound: Strideable, Bound.Stride: SignedInteger
|
||||
{
|
||||
public typealias Element = Bound
|
||||
|
||||
@frozen
|
||||
public struct BorrowingIterator_: BorrowingIteratorProtocol_, ~Copyable {
|
||||
public struct IterableIterator_: IterableIteratorProtocol_, ~Copyable {
|
||||
@usableFromInline
|
||||
internal var _current: InlineArray<1, Bound>
|
||||
|
||||
@@ -157,19 +157,19 @@ where Bound: Strideable, Bound.Stride: SignedInteger
|
||||
public var underestimatedCount_: Int { _borrowingUnderestimatedCount }
|
||||
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(self)
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
IterableIterator_(self)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
extension ClosedRange: BorrowingSequence_
|
||||
extension ClosedRange: Iterable_
|
||||
where Bound: Strideable, Bound.Stride: SignedInteger
|
||||
{
|
||||
public typealias Element = Bound
|
||||
|
||||
@frozen
|
||||
public struct BorrowingIterator_: BorrowingIteratorProtocol_, ~Copyable {
|
||||
public struct IterableIterator_: IterableIteratorProtocol_, ~Copyable {
|
||||
@usableFromInline
|
||||
internal var _current: InlineArray<1, Bound>
|
||||
|
||||
@@ -214,8 +214,8 @@ where Bound: Strideable, Bound.Stride: SignedInteger
|
||||
public var underestimatedCount_: Int { _borrowingUnderestimatedCount }
|
||||
|
||||
@inlinable
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(self)
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
IterableIterator_(self)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,13 +18,13 @@ import InternalCollectionsUtilities
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_ where Self: ~Copyable & ~Escapable, Element_: Copyable {
|
||||
extension Iterable_ where Self: ~Copyable & ~Escapable, Element_: Copyable {
|
||||
@inlinable
|
||||
package func _copyContents(
|
||||
intoPrefixOf buffer: UnsafeMutableBufferPointer<Element_>
|
||||
) -> Int {
|
||||
var target = buffer
|
||||
var it = self.makeBorrowingIterator_()
|
||||
var it = self.makeIterableIterator_()
|
||||
while target.count != 0 {
|
||||
let span = it.nextSpan_(maximumCount: target.count)
|
||||
if span.isEmpty {
|
||||
+7
-7
@@ -14,14 +14,14 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public protocol BorrowingSequence_<Element_>: ~Copyable, ~Escapable {
|
||||
public protocol Iterable_<Element_>: ~Copyable, ~Escapable {
|
||||
associatedtype Element_: ~Copyable
|
||||
associatedtype BorrowingIterator_: BorrowingIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
associatedtype IterableIterator_: IterableIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
|
||||
var underestimatedCount_: Int { get }
|
||||
|
||||
@_lifetime(borrow self)
|
||||
borrowing func makeBorrowingIterator_() -> BorrowingIterator_
|
||||
borrowing func makeIterableIterator_() -> IterableIterator_
|
||||
|
||||
func _customContainsEquatableElement_(
|
||||
_ element: borrowing Element_
|
||||
@@ -29,7 +29,7 @@ public protocol BorrowingSequence_<Element_>: ~Copyable, ~Escapable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable, Element_: ~Copyable
|
||||
{
|
||||
@@ -43,7 +43,7 @@ where
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_ where Self: Sequence {
|
||||
extension Iterable_ where Self: Sequence {
|
||||
@inlinable
|
||||
public func _customContainsEquatableElement_(_ element: borrowing Element) -> Bool? {
|
||||
nil
|
||||
@@ -51,7 +51,7 @@ extension BorrowingSequence_ where Self: Sequence {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
@@ -61,7 +61,7 @@ where
|
||||
public func _borrowingForEach<E: Error>(
|
||||
_ body: (borrowing Element_) throws(E) -> Void
|
||||
) throws(E) -> Void {
|
||||
var it = makeBorrowingIterator_()
|
||||
var it = makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: Copyable
|
||||
+13
-13
@@ -18,27 +18,27 @@ import InternalCollectionsUtilities
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable, Element_: Equatable,
|
||||
Element_: ~Copyable
|
||||
{
|
||||
@inlinable
|
||||
package func _elementsEqual<
|
||||
Other: BorrowingSequence_<Element_> & ~Copyable & ~Escapable
|
||||
Other: Iterable_<Element_> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: borrowing Other,
|
||||
) -> Bool
|
||||
where Other.Element_: ~Copyable
|
||||
{
|
||||
let it1 = self.makeBorrowingIterator_()
|
||||
let it2 = other.makeBorrowingIterator_()
|
||||
let it1 = self.makeIterableIterator_()
|
||||
let it2 = other.makeIterableIterator_()
|
||||
return it1.elementsEqual(it2)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_
|
||||
extension Iterable_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
@@ -67,28 +67,28 @@ where
|
||||
@inlinable
|
||||
package func _elementsEqual<
|
||||
E: Error,
|
||||
Other: BorrowingSequence_ & ~Copyable & ~Escapable
|
||||
Other: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: borrowing Other,
|
||||
by areEquivalent: (borrowing Element_, borrowing Other.Element_) throws(E) -> Bool
|
||||
) throws(E) -> Bool
|
||||
where Other.Element_: ~Copyable
|
||||
{
|
||||
let it1 = self.makeBorrowingIterator_()
|
||||
let it2 = other.makeBorrowingIterator_()
|
||||
let it1 = self.makeIterableIterator_()
|
||||
let it2 = other.makeIterableIterator_()
|
||||
return try it1.elementsEqual(it2, by: areEquivalent)
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable & Equatable
|
||||
{
|
||||
@inlinable
|
||||
package consuming func elementsEqual<
|
||||
Other: BorrowingIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
Other: IterableIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
) -> Bool
|
||||
@@ -114,7 +114,7 @@ where
|
||||
|
||||
@inlinable
|
||||
package consuming func _directElementsEqual<
|
||||
Other: BorrowingIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
Other: IterableIteratorProtocol_<Element_> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
) -> Bool
|
||||
@@ -175,7 +175,7 @@ where
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
@@ -183,7 +183,7 @@ where
|
||||
@inlinable
|
||||
package consuming func elementsEqual<
|
||||
E: Error,
|
||||
Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable
|
||||
Other: IterableIteratorProtocol_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
by areEquivalent: (borrowing Element_, borrowing Other.Element_) throws(E) -> Bool
|
||||
+3
-3
@@ -14,7 +14,7 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
@@ -30,7 +30,7 @@ where
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public struct BorrowingFilter<
|
||||
Base: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable
|
||||
Base: IterableIteratorProtocol_ & ~Copyable & ~Escapable
|
||||
>: ~Copyable, ~Escapable
|
||||
where Base.Element_: ~Copyable {
|
||||
public typealias Element_ = Base.Element_
|
||||
@@ -55,7 +55,7 @@ where Base.Element_: ~Copyable {
|
||||
// FIXME: Sendable
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingFilter: BorrowingIteratorProtocol_
|
||||
extension BorrowingFilter: IterableIteratorProtocol_
|
||||
where Base: ~Copyable & ~Escapable, Base.Element_: ~Copyable {
|
||||
@_lifetime(&self)
|
||||
public mutating func nextSpan_(maximumCount: Int) -> Span<Element_> {
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
@@ -30,7 +30,7 @@ where
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public struct BorrowingMapProducer<
|
||||
Base: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable,
|
||||
Base: IterableIteratorProtocol_ & ~Copyable & ~Escapable,
|
||||
Element: ~Copyable,
|
||||
Error: Swift.Error
|
||||
>: ~Copyable, ~Escapable {
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
+2
-2
@@ -18,14 +18,14 @@ import InternalCollectionsUtilities
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where
|
||||
Self: ~Copyable & ~Escapable,
|
||||
Element_: ~Copyable
|
||||
{
|
||||
@inlinable
|
||||
internal consuming func _spanwiseZip<
|
||||
Other: BorrowingIteratorProtocol_ & ~Copyable & ~Escapable,
|
||||
Other: IterableIteratorProtocol_ & ~Copyable & ~Escapable,
|
||||
State: ~Copyable, E: Error
|
||||
>(
|
||||
state: inout State,
|
||||
+5
-5
@@ -18,7 +18,7 @@ import InternalCollectionsUtilities
|
||||
#endif
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public protocol BorrowingIteratorProtocol_<Element_>: ~Copyable, ~Escapable {
|
||||
public protocol IterableIteratorProtocol_<Element_>: ~Copyable, ~Escapable {
|
||||
associatedtype Element_: ~Copyable
|
||||
|
||||
/// Advance the iterator, returning an ephemeral span over the elements
|
||||
@@ -85,7 +85,7 @@ public protocol BorrowingIteratorProtocol_<Element_>: ~Copyable, ~Escapable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where Self: ~Copyable & ~Escapable, Element_: ~Copyable {
|
||||
@_lifetime(&self)
|
||||
@_lifetime(self: copy self)
|
||||
@@ -96,7 +96,7 @@ where Self: ~Copyable & ~Escapable, Element_: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where Self: ~Copyable & ~Escapable, Element_: ~Copyable {
|
||||
@_lifetime(self: copy self)
|
||||
@inlinable
|
||||
@@ -112,7 +112,7 @@ where Self: ~Copyable & ~Escapable, Element_: ~Copyable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_ where Self: ~Copyable & ~Escapable {
|
||||
extension IterableIteratorProtocol_ where Self: ~Copyable & ~Escapable {
|
||||
#if false // FIXME: This doesn't work, but it should?
|
||||
@_lifetime(&self)
|
||||
@_lifetime(self: copy self)
|
||||
@@ -125,7 +125,7 @@ extension BorrowingIteratorProtocol_ where Self: ~Copyable & ~Escapable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingIteratorProtocol_
|
||||
extension IterableIteratorProtocol_
|
||||
where Self: ~Copyable & ~Escapable, Element_: Copyable
|
||||
{
|
||||
@_lifetime(self: copy self)
|
||||
@@ -16,7 +16,7 @@
|
||||
/// A borrowing iterator that provides access to the elements of a single
|
||||
/// span through a `BorrowingIteratorProtocol` interface.
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public struct SpanIterator<Element_>: BorrowingIteratorProtocol_, ~Copyable, ~Escapable
|
||||
public struct SpanIterator<Element_>: IterableIteratorProtocol_, ~Copyable, ~Escapable
|
||||
where Element_: ~Copyable
|
||||
{
|
||||
@usableFromInline
|
||||
|
||||
@@ -313,9 +313,9 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
@@ -334,7 +334,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `newElements`.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func append<S: Iterable_<Element> & ~Copyable & ~Escapable>(
|
||||
copying newElements: borrowing S
|
||||
) {
|
||||
self._append(copying: newElements)
|
||||
@@ -375,7 +375,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`. @available(SwiftStdlib 5.0, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: S
|
||||
) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import ContainersPreview
|
||||
extension RigidDeque where Element: ~Copyable {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@frozen
|
||||
public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol_ {
|
||||
public struct BorrowingIterator: ~Escapable, IterableIteratorProtocol_ {
|
||||
public typealias Element_ = Element
|
||||
|
||||
@usableFromInline
|
||||
@@ -60,7 +60,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator {
|
||||
public borrowing func makeIterableIterator_() -> BorrowingIterator {
|
||||
BorrowingIterator(_deque: self)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -132,7 +132,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -187,7 +187,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -208,7 +208,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
S: Iterable_<Element> & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
|
||||
@@ -365,7 +365,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
newCount: Int
|
||||
) {
|
||||
let expectedCount = self.count + newCount
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
insert(addingCount: newCount, at: index) { target in
|
||||
it._copyContents_(into: &target)
|
||||
}
|
||||
|
||||
@@ -290,13 +290,13 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
// 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 BorrowingSequence_.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
|
||||
@@ -306,12 +306,12 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S,
|
||||
exactCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
self.prepend(addingCount: exactCount) { target in
|
||||
let span = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
target._append(copying: span)
|
||||
@@ -333,7 +333,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func prepend<S: Iterable_<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items)
|
||||
@@ -437,7 +437,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & Sequence<Element>>(
|
||||
public mutating func prepend<S: Iterable_<Element> & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items)
|
||||
@@ -453,7 +453,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & Collection<Element>>(
|
||||
public mutating func prepend<S: Iterable_<Element> & Collection<Element>>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items, exactCount: items.count)
|
||||
|
||||
@@ -466,7 +466,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
) {
|
||||
|
||||
let expectedCount = self.count - subrange.count + newCount
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
self.replace(removing: subrange, addingCount: newCount) { target in
|
||||
it._copyContents_(into: &target)
|
||||
}
|
||||
|
||||
@@ -300,9 +300,9 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
@@ -323,7 +323,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`, when amortized
|
||||
/// over many similar invocations on the same deque
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func append<S: Iterable_<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._append(copying: items)
|
||||
@@ -374,7 +374,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// amortized over many similar invocations over the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: S
|
||||
) {
|
||||
|
||||
@@ -26,7 +26,7 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator {
|
||||
public borrowing func makeIterableIterator_() -> BorrowingIterator {
|
||||
BorrowingIterator(_deque: self._storage)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -145,7 +145,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: borrowing S
|
||||
@@ -184,7 +184,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
@@ -203,7 +203,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
S: Iterable_<Element> & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
|
||||
@@ -383,7 +383,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
newCount: Int
|
||||
) {
|
||||
let expectedCount = self.count + newCount
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
insert(addingCount: newCount, at: index) { target in
|
||||
it._copyContents_(into: &target)
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
// 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
|
||||
@@ -338,12 +338,12 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S,
|
||||
exactCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
self.prepend(addingCount: exactCount) { target in
|
||||
let span = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
target._append(copying: span)
|
||||
@@ -367,7 +367,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// over many similar invocations on the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
S: Iterable_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -479,7 +479,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// over many similar invocations on the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
S: Iterable_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -498,7 +498,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// over many similar invocations on the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
S: Iterable_<Element> & Collection<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
|
||||
@@ -475,7 +475,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
) {
|
||||
|
||||
let expectedCount = self.count - subrange.count + newCount
|
||||
var it = items.makeBorrowingIterator_()
|
||||
var it = items.makeIterableIterator_()
|
||||
self.replace(removing: subrange, addingCount: newCount) { target in
|
||||
it._copyContents_(into: &target)
|
||||
}
|
||||
|
||||
@@ -1472,7 +1472,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.makeIterableIterator_()
|
||||
.map { 2 * $0 }
|
||||
.collect(into: UniqueArray.self)
|
||||
expectEqual(transformed.count, c)
|
||||
@@ -1485,7 +1485,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.makeIterableIterator_()
|
||||
.filter { !$0.isMultiple(of: 6) }
|
||||
.copy()
|
||||
.collect(into: UniqueArray.self)
|
||||
|
||||
@@ -258,7 +258,7 @@ class RigidDictionaryTests: CollectionTestCase {
|
||||
expectEqual(keys.count, i + 1)
|
||||
expectEqual(keys.capacity, capacity)
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
var it = keys.makeBorrowingIterator_()
|
||||
var it = keys.makeIterableIterator_()
|
||||
var actual: Set<Int> = []
|
||||
while true {
|
||||
let next = it.nextSpan_()
|
||||
@@ -323,7 +323,7 @@ class RigidDictionaryTests: CollectionTestCase {
|
||||
|
||||
var seen: Set<Int> = []
|
||||
let indices = d.indices
|
||||
var it = indices.makeBorrowingIterator_()
|
||||
var it = indices.makeIterableIterator_()
|
||||
while true {
|
||||
let next = it.nextSpan_()
|
||||
if next.isEmpty { break }
|
||||
|
||||
@@ -301,7 +301,7 @@ class RigidSetTests: CollectionTestCase {
|
||||
s.insert(tracker.instance(for: i))
|
||||
|
||||
var expected = Set(0 ... i)
|
||||
var it = s.makeBorrowingIterator_()
|
||||
var it = s.makeIterableIterator_()
|
||||
while true {
|
||||
let next = it.nextSpan_(maximumCount: maximumCount)
|
||||
guard !next.isEmpty else { break }
|
||||
|
||||
@@ -146,7 +146,7 @@ class UniqueDictionaryTests: CollectionTestCase {
|
||||
expectEqual(keys.count, i + 1)
|
||||
expectEqual(keys.capacity, capacity)
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
var it = keys.makeBorrowingIterator_()
|
||||
var it = keys.makeIterableIterator_()
|
||||
var actual: Set<Int> = []
|
||||
while true {
|
||||
let next = it.nextSpan_()
|
||||
@@ -210,7 +210,7 @@ class UniqueDictionaryTests: CollectionTestCase {
|
||||
|
||||
var seen: Set<Int> = []
|
||||
let indices = d.indices
|
||||
var it = indices.makeBorrowingIterator_()
|
||||
var it = indices.makeIterableIterator_()
|
||||
while true {
|
||||
let next = it.nextSpan_()
|
||||
if next.isEmpty { break }
|
||||
|
||||
@@ -64,9 +64,9 @@ final class BorrowingSequenceTests: XCTestCase {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension BorrowingSequence_ where Self: ~Copyable & ~Escapable, Element_: Copyable {
|
||||
extension Iterable_ where Self: ~Copyable & ~Escapable, Element_: Copyable {
|
||||
func collectViaBorrowing() -> [Element_] {
|
||||
var borrowIterator = makeBorrowingIterator_()
|
||||
var borrowIterator = makeIterableIterator_()
|
||||
var result: [Element_] = []
|
||||
while true {
|
||||
let span = borrowIterator.nextSpan_(maximumCount: .max)
|
||||
|
||||
@@ -127,7 +127,7 @@ public func expectIterableContents<
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterablePayloads<
|
||||
Payload: Equatable,
|
||||
E1: BorrowingSequence_<LifetimeTrackedStruct<Payload>> & ~Copyable & ~Escapable,
|
||||
E1: Iterable_<LifetimeTrackedStruct<Payload>> & ~Copyable & ~Escapable,
|
||||
C2: Collection<Payload>,
|
||||
>(
|
||||
_ left: borrowing E1,
|
||||
@@ -137,7 +137,7 @@ public func expectIterablePayloads<
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) where E1.Element_: ~Copyable {
|
||||
var it1 = left.makeBorrowingIterator_()
|
||||
var it1 = left.makeIterableIterator_()
|
||||
var it2 = right.makeIterator()
|
||||
var i = 0
|
||||
while true {
|
||||
@@ -174,7 +174,7 @@ public func expectIterablePayloads<
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterablePayloads<
|
||||
Payload: Equatable,
|
||||
E1: BorrowingSequence_<LifetimeTracked<Payload>> & ~Copyable & ~Escapable,
|
||||
E1: Iterable_<LifetimeTracked<Payload>> & ~Copyable & ~Escapable,
|
||||
C2: Collection<Payload>,
|
||||
>(
|
||||
_ left: borrowing E1,
|
||||
@@ -184,7 +184,7 @@ public func expectIterablePayloads<
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
var it1 = left.makeBorrowingIterator_()
|
||||
var it1 = left.makeIterableIterator_()
|
||||
var it2 = right.makeIterator()
|
||||
var i = 0
|
||||
while true {
|
||||
@@ -220,8 +220,8 @@ public func expectIterablePayloads<
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterablesWithEquivalentElements<
|
||||
S1: BorrowingSequence_ & ~Copyable & ~Escapable,
|
||||
S2: BorrowingSequence_ & ~Copyable & ~Escapable
|
||||
S1: Iterable_ & ~Copyable & ~Escapable,
|
||||
S2: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ left: borrowing S1,
|
||||
_ right: borrowing S2,
|
||||
@@ -245,8 +245,8 @@ where
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterablesWithEqualElements<
|
||||
Element: Equatable,
|
||||
S1: BorrowingSequence_<Element> & ~Copyable & ~Escapable,
|
||||
S2: BorrowingSequence_<Element> & ~Copyable & ~Escapable,
|
||||
S1: Iterable_<Element> & ~Copyable & ~Escapable,
|
||||
S2: Iterable_<Element> & ~Copyable & ~Escapable,
|
||||
>(
|
||||
_ left: borrowing S1,
|
||||
_ right: borrowing S2,
|
||||
@@ -269,7 +269,7 @@ where
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterableContents<
|
||||
Element: Equatable,
|
||||
S1: BorrowingSequence_<Element> & ~Copyable & ~Escapable,
|
||||
S1: Iterable_<Element> & ~Copyable & ~Escapable,
|
||||
C2: Collection<Element>,
|
||||
>(
|
||||
_ left: borrowing S1,
|
||||
@@ -279,7 +279,7 @@ public func expectIterableContents<
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
var it1 = left.makeBorrowingIterator_()
|
||||
var it1 = left.makeIterableIterator_()
|
||||
var it2 = right.makeIterator()
|
||||
while true {
|
||||
let span = it1.nextSpan_()
|
||||
@@ -310,7 +310,7 @@ public func expectIterableContents<
|
||||
/// Check if `left` and `right` contain equal elements in the same order.
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public func expectIterableContents<
|
||||
S1: BorrowingSequence_ & ~Copyable & ~Escapable,
|
||||
S1: Iterable_ & ~Copyable & ~Escapable,
|
||||
C2: Collection,
|
||||
>(
|
||||
_ left: borrowing S1,
|
||||
@@ -322,7 +322,7 @@ public func expectIterableContents<
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) where S1.Element_: ~Copyable {
|
||||
var it1 = left.makeBorrowingIterator_()
|
||||
var it1 = left.makeIterableIterator_()
|
||||
var it2 = right.makeIterator()
|
||||
var offset = 0
|
||||
while true {
|
||||
|
||||
@@ -22,7 +22,7 @@ import ContainersPreview
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
@inlinable
|
||||
public func checkIterable<
|
||||
S: BorrowingSequence_ & ~Copyable & ~Escapable,
|
||||
S: Iterable_ & ~Copyable & ~Escapable,
|
||||
Expected: Sequence<S.Element_>
|
||||
>(
|
||||
_ iterable: borrowing S,
|
||||
@@ -40,7 +40,7 @@ public func checkIterable<
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
@inlinable
|
||||
public func checkIterable<
|
||||
S: BorrowingSequence_ & ~Copyable & ~Escapable,
|
||||
S: Iterable_ & ~Copyable & ~Escapable,
|
||||
Expected: Sequence<S.Element_>
|
||||
>(
|
||||
_ iterable: borrowing S,
|
||||
@@ -60,7 +60,7 @@ public func checkIterable<
|
||||
let spanShapes: [Range<Int>] = {
|
||||
var r: [Range<Int>] = []
|
||||
var pos = 0
|
||||
var it = iterable.makeBorrowingIterator_()
|
||||
var it = iterable.makeIterableIterator_()
|
||||
while true {
|
||||
let origPos = pos
|
||||
let span = it.nextSpan_()
|
||||
@@ -79,7 +79,7 @@ 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.makeIterableIterator_()
|
||||
var spanIndex = 0
|
||||
while true {
|
||||
let span = it.nextSpan_()
|
||||
@@ -100,7 +100,7 @@ public func checkIterable<
|
||||
// Check that we can iterate one by one.
|
||||
do {
|
||||
var pos = 0
|
||||
var it = iterable.makeBorrowingIterator_()
|
||||
var it = iterable.makeIterableIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan_(maximumCount: 1)
|
||||
if span.isEmpty { break }
|
||||
@@ -116,7 +116,7 @@ public func checkIterable<
|
||||
// Check that we can iterate with huge maximum counts
|
||||
do {
|
||||
var pos = 0
|
||||
var it = iterable.makeBorrowingIterator_()
|
||||
var it = iterable.makeIterableIterator_()
|
||||
var spanIndex = 0
|
||||
while true {
|
||||
let span = it.nextSpan_(maximumCount: Int.max)
|
||||
|
||||
@@ -76,7 +76,7 @@ package struct _StaccatoParameters {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
public struct _StaccatoBorrowingIterator<Element: ~Copyable>: BorrowingIteratorProtocol_, ~Escapable {
|
||||
public struct _StaccatoBorrowingIterator<Element: ~Copyable>: IterableIteratorProtocol_, ~Escapable {
|
||||
public typealias Element_ = Element
|
||||
|
||||
internal let _contents: Span<Element>
|
||||
@@ -116,13 +116,13 @@ public struct _StaccatoIndex: Comparable {
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension StaccatoContainer: BorrowingSequence_ where Element: ~Copyable {
|
||||
public typealias BorrowingIterator_ = _StaccatoBorrowingIterator<Element> // FIXME rdar://150240032
|
||||
extension StaccatoContainer: Iterable_ where Element: ~Copyable {
|
||||
public typealias IterableIterator_ = _StaccatoBorrowingIterator<Element> // FIXME rdar://150240032
|
||||
|
||||
public var underestimatedCount_: Int { count }
|
||||
|
||||
public func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(contents: _contents.span, params: _params)
|
||||
public func makeIterableIterator_() -> IterableIterator_ {
|
||||
IterableIterator_(contents: _contents.span, params: _params)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user