mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
Disambiguate ContainersPreview and stdlib
Adds trailing underscores to the BorrowingSequence protocols and requirements, in order to allow both parallel conformances and the ability to evolve the requirements in this package.
This commit is contained in:
1 parent
4c04822689
commit
a99a015934
49 files changed
+350
-363
No files matched your search
@@ -314,11 +314,11 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
var it = items.makeBorrowingIterator()
|
||||
var it = items.makeBorrowingIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan()
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
self.append(copying: span)
|
||||
}
|
||||
@@ -336,7 +336,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `newElements`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func append<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
copying newElements: borrowing S
|
||||
) {
|
||||
self._append(copying: newElements)
|
||||
@@ -378,7 +378,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: S
|
||||
) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import ContainersPreview
|
||||
extension RigidDeque where Element: ~Copyable {
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@frozen
|
||||
public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol {
|
||||
public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol_ {
|
||||
@usableFromInline
|
||||
internal var _currentSegment: Span<Element>
|
||||
|
||||
@@ -46,7 +46,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
@_alwaysEmitIntoClient
|
||||
@_lifetime(copy self)
|
||||
@_lifetime(self: copy self)
|
||||
public mutating func nextSpan(maximumCount: Int) -> Span<Element> {
|
||||
public mutating func nextSpan_(maximumCount: Int) -> Span<Element> {
|
||||
let result = _currentSegment._trim(first: maximumCount)
|
||||
if _currentSegment.isEmpty {
|
||||
_currentSegment = _nextSegment
|
||||
@@ -58,7 +58,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator() -> BorrowingIterator {
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator {
|
||||
BorrowingIterator(_deque: self)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -133,7 +133,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -189,7 +189,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
@@ -211,7 +211,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & Collection<Element>
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
|
||||
@@ -365,12 +365,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
|
||||
|
||||
@@ -291,13 +291,13 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<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 BorrowingSequence_.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
|
||||
@@ -308,14 +308,14 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S,
|
||||
exactCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator()
|
||||
var it = items.makeBorrowingIterator_()
|
||||
self.prepend(addingCount: exactCount) { target in
|
||||
let span = it.nextSpan(maximumCount: target.freeCapacity)
|
||||
let span = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
target._append(copying: span)
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items)
|
||||
@@ -442,7 +442,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence<Element> & Sequence<Element>>(
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items)
|
||||
@@ -459,7 +459,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: BorrowingSequence<Element> & Collection<Element>>(
|
||||
public mutating func prepend<S: BorrowingSequence_<Element> & Collection<Element>>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._prepend(copying: items, exactCount: items.count)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -301,11 +301,11 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(copying items: borrowing S) {
|
||||
var it = items.makeBorrowingIterator()
|
||||
var it = items.makeBorrowingIterator_()
|
||||
while true {
|
||||
let span = it.nextSpan()
|
||||
let span = it.nextSpan_()
|
||||
if span.isEmpty { break }
|
||||
self.append(copying: span)
|
||||
}
|
||||
@@ -325,7 +325,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// over many similar invocations on the same deque
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
public mutating func append<S: BorrowingSequence_<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
self._append(copying: items)
|
||||
@@ -377,7 +377,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
S: BorrowingSequence_<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 makeBorrowingIterator_() -> BorrowingIterator {
|
||||
BorrowingIterator(_deque: self._storage)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -155,7 +155,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: borrowing S
|
||||
@@ -195,7 +195,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
@@ -215,7 +215,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: BorrowingSequence<Element> & Collection<Element>
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
|
||||
@@ -383,12 +383,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
|
||||
|
||||
@@ -323,7 +323,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<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
|
||||
@@ -340,14 +340,14 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S,
|
||||
exactCount: Int
|
||||
) {
|
||||
var it = items.makeBorrowingIterator()
|
||||
var it = items.makeBorrowingIterator_()
|
||||
self.prepend(addingCount: exactCount) { target in
|
||||
let span = it.nextSpan(maximumCount: target.freeCapacity)
|
||||
let span = it.nextSpan_(maximumCount: target.freeCapacity)
|
||||
target._append(copying: span)
|
||||
}
|
||||
}
|
||||
@@ -370,7 +370,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
S: BorrowingSequence_<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -482,7 +482,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
S: BorrowingSequence_<Element> & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
@@ -502,7 +502,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<
|
||||
S: BorrowingSequence<Element> & Collection<Element>
|
||||
S: BorrowingSequence_<Element> & Collection<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user