mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
[BasicContainers, ContainersPreview, DequeModule] More SuppressedAssociatedTypesWithDefaults fixups
This commit is contained in:
26 files changed
+129
-42
No files matched your search
@@ -234,7 +234,9 @@ extension RigidArray where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try self.append(addingCount: newItemCount) { target throws(E) in
|
||||
while !target.isFull {
|
||||
guard try producer.generate(into: &target) else { break }
|
||||
@@ -261,7 +263,9 @@ extension RigidArray where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
while !done {
|
||||
try self.append(addingCount: freeCapacity) { target throws(E) in
|
||||
|
||||
@@ -304,7 +304,9 @@ extension RigidArray where Element: ~Copyable {
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P,
|
||||
at index: Int
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try insert(addingCount: newItemCount, at: index) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -454,7 +454,9 @@ extension RigidArray where Element: ~Copyable {
|
||||
removing subrange: Range<Int>,
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try replace(
|
||||
removing: subrange,
|
||||
addingCount: newItemCount
|
||||
|
||||
@@ -57,7 +57,9 @@ extension RigidSet where Element: ~Copyable {
|
||||
>(
|
||||
capacity: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
self.init(capacity: capacity)
|
||||
try self.insert(maximumCount: capacity, from: &producer)
|
||||
}
|
||||
|
||||
@@ -173,7 +173,9 @@ extension RigidSet where Element: ~Copyable {
|
||||
>(
|
||||
maximumCount: Int? = nil,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try self.insert(
|
||||
maximumCount: maximumCount ?? freeCapacity
|
||||
) { target throws(E) in
|
||||
|
||||
@@ -206,7 +206,9 @@ extension UniqueArray where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
_ensureFreeCapacity(newItemCount)
|
||||
try _storage.append(addingCount: newItemCount, from: &producer)
|
||||
}
|
||||
@@ -230,7 +232,9 @@ extension UniqueArray where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
while !done {
|
||||
let c = Swift.max(producer.underestimatedCount, 1)
|
||||
|
||||
@@ -267,7 +267,9 @@ extension UniqueArray where Element: ~Copyable {
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P,
|
||||
at index: Int
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try insert(addingCount: newItemCount, at: index) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -392,7 +392,9 @@ extension UniqueArray where Element: ~Copyable {
|
||||
removing subrange: Range<Int>,
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try replace(removing: subrange, addingCount: newItemCount) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -57,7 +57,9 @@ extension UniqueSet where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
minimumCapacity: Int? = nil, from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
let c = producer.underestimatedCount
|
||||
if let minimumCapacity {
|
||||
self.init(minimumCapacity: Swift.min(minimumCapacity, c))
|
||||
|
||||
@@ -86,7 +86,9 @@ extension UniqueSet where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
while !done {
|
||||
_ensureFreeCapacity(Swift.max(producer.underestimatedCount, 1))
|
||||
|
||||
@@ -28,7 +28,9 @@ where
|
||||
Other: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: borrowing Other,
|
||||
) -> Bool {
|
||||
) -> Bool
|
||||
where Other.Element: ~Copyable
|
||||
{
|
||||
let it1 = self.makeBorrowingIterator()
|
||||
let it2 = other.makeBorrowingIterator()
|
||||
return it1.elementsEqual(it2)
|
||||
@@ -69,7 +71,9 @@ where
|
||||
>(
|
||||
_ other: borrowing Other,
|
||||
by areEquivalent: (borrowing Element, borrowing Other.Element) throws(E) -> Bool
|
||||
) throws(E) -> Bool {
|
||||
) throws(E) -> Bool
|
||||
where Other.Element: ~Copyable
|
||||
{
|
||||
let it1 = self.makeBorrowingIterator()
|
||||
let it2 = other.makeBorrowingIterator()
|
||||
return try it1.elementsEqual(it2, by: areEquivalent)
|
||||
@@ -87,7 +91,9 @@ where
|
||||
Other: BorrowingIteratorProtocol<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
) -> Bool {
|
||||
) -> Bool
|
||||
where Other.Element: ~Copyable
|
||||
{
|
||||
var result = true
|
||||
_spanwiseZip(state: &result, with: other) { state, a, b in
|
||||
if a.isEmpty || b.isEmpty {
|
||||
@@ -111,7 +117,9 @@ where
|
||||
Other: BorrowingIteratorProtocol<Element> & ~Copyable & ~Escapable
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
) -> Bool {
|
||||
) -> 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
|
||||
// variant in the #else branch would be preferable, but it doesn't work yet.
|
||||
@@ -179,7 +187,9 @@ where
|
||||
>(
|
||||
_ other: consuming Other,
|
||||
by areEquivalent: (borrowing Element, borrowing Other.Element) throws(E) -> Bool
|
||||
) throws(E) -> Bool {
|
||||
) throws(E) -> Bool
|
||||
where Other.Element: ~Copyable
|
||||
{
|
||||
var result = true
|
||||
try _spanwiseZip(state: &result, with: other) { state, a, b throws(E) in
|
||||
assert(a.count == b.count || a.isEmpty || b.isEmpty)
|
||||
|
||||
@@ -31,7 +31,9 @@ where
|
||||
state: inout State,
|
||||
with other: consuming Other,
|
||||
by process: (inout State, Span<Element>, Span<Other.Element>) throws(E) -> Bool
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where Other.Element: ~Copyable
|
||||
{
|
||||
#if true // FIXME: rdar://150228920 Exclusive access scopes aren't expanded enough
|
||||
// Note: This is the less efficient implementation of spanwiseZip. The
|
||||
// variant in the #else branch would be preferable, but it doesn't work yet.
|
||||
|
||||
@@ -61,6 +61,7 @@ where
|
||||
) 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()
|
||||
while true {
|
||||
@@ -90,7 +91,11 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable & Equatable {
|
||||
@inlinable
|
||||
public func elementsEqual<OtherSequence: BorrowingSequence<Element>>(
|
||||
_ other: borrowing OtherSequence
|
||||
) -> Bool where OtherSequence: ~Copyable & ~Escapable {
|
||||
) -> Bool
|
||||
where
|
||||
OtherSequence: ~Copyable & ~Escapable,
|
||||
OtherSequence.Element: ~Copyable
|
||||
{
|
||||
return self.elementsEqual(other, by: ==)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,9 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
|
||||
>(
|
||||
minimumCapacity: Int? = nil,
|
||||
from producer: consuming P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
self.init(minimumCapacity: minimumCapacity ?? producer.underestimatedCount)
|
||||
try self.append(from: producer)
|
||||
}
|
||||
@@ -59,7 +61,9 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: consuming P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
while true {
|
||||
let c = Swift.max(producer.underestimatedCount, self.freeCapacity)
|
||||
try self.append(addingCount: c) { target throws(E) in
|
||||
|
||||
@@ -149,7 +149,9 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
|
||||
removing subrange: some RangeExpression2<Index>,
|
||||
addingCount: Int,
|
||||
from producer: inout P
|
||||
) throws(P.ProducerError) {
|
||||
) throws(P.ProducerError)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try replace(
|
||||
removing: subrange.relative(to: self),
|
||||
consumingWith: { _ in },
|
||||
@@ -309,7 +311,9 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
|
||||
addingCount newItemCount: Int,
|
||||
at index: Index,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try self.insert(addingCount: newItemCount, at: index) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
}
|
||||
@@ -344,7 +348,9 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try insert(addingCount: newItemCount, at: endIndex, from: &producer)
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try self.append(addingCount: newItemCount) { target throws(E) in
|
||||
while !target.isFull {
|
||||
guard try producer.generate(into: &target) else { break }
|
||||
@@ -229,7 +231,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
try self.append(
|
||||
addingCount: freeCapacity
|
||||
|
||||
@@ -90,7 +90,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
>(
|
||||
capacity: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
self.init(capacity: capacity)
|
||||
try self.append(from: &producer)
|
||||
}
|
||||
|
||||
@@ -245,7 +245,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P,
|
||||
at index: Int
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try insert(addingCount: newItemCount, at: index) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -215,7 +215,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int? = nil,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try self.prepend(
|
||||
addingCount: newItemCount ?? freeCapacity
|
||||
) { target throws(E) in
|
||||
|
||||
@@ -325,7 +325,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
removing subrange: Range<Int>,
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try replace(
|
||||
removing: subrange,
|
||||
addingCount: newItemCount
|
||||
|
||||
@@ -195,7 +195,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
_ensureFreeCapacity(newItemCount)
|
||||
try _storage.append(addingCount: newItemCount, from: &producer)
|
||||
}
|
||||
@@ -219,7 +221,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
while !done {
|
||||
let c = Swift.max(producer.underestimatedCount, 1)
|
||||
|
||||
@@ -93,7 +93,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
>(
|
||||
capacity: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
self.init(capacity: capacity)
|
||||
try self.append(addingCount: capacity, from: &producer)
|
||||
}
|
||||
@@ -113,7 +115,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
self.init(capacity: producer.underestimatedCount)
|
||||
try self.append(from: &producer)
|
||||
}
|
||||
|
||||
@@ -257,7 +257,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P,
|
||||
at index: Int
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try insert(addingCount: newItemCount, at: index) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -206,7 +206,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
>(
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
_ensureFreeCapacity(newItemCount)
|
||||
try _storage._handle.uncheckedPrepend(
|
||||
addingCount: newItemCount
|
||||
@@ -237,7 +239,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
P: Producer<Element, E> & ~Copyable & ~Escapable
|
||||
>(
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
var done = false
|
||||
while !done {
|
||||
let c = Swift.max(producer.underestimatedCount, 1)
|
||||
|
||||
@@ -334,7 +334,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
removing subrange: Range<Int>,
|
||||
addingCount newItemCount: Int,
|
||||
from producer: inout P
|
||||
) throws(E) {
|
||||
) throws(E)
|
||||
where P.Element: ~Copyable
|
||||
{
|
||||
try replace(removing: subrange, addingCount: newItemCount) { target throws(E) in
|
||||
while !target.isFull, try producer.generate(into: &target) {
|
||||
// Do nothing
|
||||
|
||||
@@ -136,7 +136,7 @@ public func expectIterablePayloads<
|
||||
trapping: Bool = false,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
) where E1.Element: ~Copyable {
|
||||
var it1 = left.makeBorrowingIterator()
|
||||
var it2 = right.makeIterator()
|
||||
var i = 0
|
||||
@@ -230,7 +230,11 @@ public func expectIterablesWithEquivalentElements<
|
||||
trapping: Bool = false,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
)
|
||||
where
|
||||
S1.Element: ~Copyable,
|
||||
S2.Element: ~Copyable
|
||||
{
|
||||
if left._elementsEqual(right, by: areEquivalent) { return }
|
||||
_expectFailure(
|
||||
"Containers do not have equivalent elements",
|
||||
@@ -250,7 +254,11 @@ public func expectIterablesWithEqualElements<
|
||||
trapping: Bool = false,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
)
|
||||
where
|
||||
S1.Element: ~Copyable,
|
||||
S2.Element: ~Copyable
|
||||
{
|
||||
if left._elementsEqual(right) { return }
|
||||
_expectFailure(
|
||||
"Containers do not have equal elements",
|
||||
@@ -313,7 +321,7 @@ public func expectIterableContents<
|
||||
trapping: Bool = false,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
) where S1.Element: ~Copyable {
|
||||
var it1 = left.makeBorrowingIterator()
|
||||
var it2 = right.makeIterator()
|
||||
var offset = 0
|
||||
|
||||
Reference in new issue
Block a user