mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Use Iterable from the Standard Library, replacing the local definition
This commit is contained in:
68 files changed
+565
-921
No files matched your search
@@ -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<Element>
|
||||
Source: Iterable & Sequence<Element>
|
||||
>(
|
||||
copying newElements: Source
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
) throws(Source.Failure)
|
||||
where Source.Element == Element {
|
||||
try self._append(copying: newElements)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -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<Element>.BorrowingIterator_
|
||||
extension UniqueArray: Iterable where Element: ~Copyable {
|
||||
public typealias BorrowingIterator = Span<Element>.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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ extension UniqueArray /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: Iterable_ & ~Copyable & ~Escapable>(
|
||||
public init<Source: Iterable & ~Copyable & ~Escapable>(
|
||||
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<Source: Iterable_ & Sequence<Element>>(
|
||||
public init<Source: Iterable & Sequence<Element>>(
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user