Align Iterable with proposal

Adds throwing and ~Escapable elements
This commit is contained in:
Nate Cook authored and Karoy Lorentey committed 2026-06-17 14:27:29 -07:00
1 parent 4bda43f4a9
commit dca015d7e8
37 files changed
+234 -221

No files matched your search

@@ -349,12 +349,12 @@ extension RigidArray {
#if compiler(>=6.4) && UnstableContainersPreview
@inlinable
internal mutating func _append<
Source: Iterable_<Element> & ~Copyable & ~Escapable
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
>(
copying newElements: borrowing Source
) {
) throws(E) {
let target = _freeSpace
_count += newElements._copyContents(intoPrefixOf: target)
_count += try newElements._copyContents(intoPrefixOf: target)
}
#endif
@@ -371,11 +371,11 @@ extension RigidArray {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
Source: Iterable_<Element> & ~Copyable & ~Escapable
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
>(
copying newElements: borrowing Source
) {
_append(copying: newElements)
) throws(E) {
try _append(copying: newElements)
}
#endif
@@ -413,7 +413,7 @@ extension RigidArray {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
Source: Iterable_<Element> & Sequence<Element>
Source: Iterable_<Element, Never> & Sequence<Element>
>(copying newElements: Source) {
_append(copying: newElements)
}
@@ -124,12 +124,12 @@ extension RigidArray /*where Element: Copyable*/ {
/// The container must not contain more than `capacity` elements.
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_<Element> & ~Copyable & ~Escapable>(
public init<Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E>(
capacity: Int,
copying contents: borrowing Source
) {
) throws(E) {
self.init(capacity: capacity)
self.append(copying: contents)
try self.append(copying: contents)
}
#endif
@@ -145,7 +145,7 @@ extension RigidArray /*where Element: Copyable*/ {
/// The container must not contain more than `capacity` elements.
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_<Element> & Sequence<Element>>(
public init<Source: Iterable_<Element, Never> & Sequence<Element>>(
capacity: Int,
copying contents: Source
) {
@@ -414,7 +414,7 @@ extension RigidArray {
at index: Int,
copying items: borrowing C,
newCount: Int
) {
) where C.Failure == Never {
var it = items.makeIterableIterator_()
insert(addingCount: newCount, at: index) { target in
while !target.isFull {
@@ -479,7 +479,7 @@ extension RigidArray {
C: Container<Element> & ~Copyable & ~Escapable
>(
copying newElements: borrowing C, at index: Int
) {
) where C.Failure == Never {
_insertContainer(
at: index, copying: newElements, newCount: newElements.count)
}
@@ -539,7 +539,7 @@ extension RigidArray {
C: Container<Element> & Collection<Element>
>(
copying newElements: borrowing C, at index: Int
) {
) where C.Failure == Never {
_insertContainer(
at: index, copying: newElements, newCount: newElements.count)
}
@@ -590,7 +590,7 @@ extension RigidArray {
removing subrange: Range<Int>,
copyingContainer items: borrowing C,
newCount: Int
) {
) where C.Failure == Never {
var it = items.makeIterableIterator_()
self.replace(removing: subrange, addingCount: newCount) { target in
while !target.isFull {
@@ -668,7 +668,7 @@ extension RigidArray {
>(
removing subrange: Range<Int>,
copying newElements: borrowing C
) {
) where C.Failure == Never {
_replace(
removing: subrange,
copyingContainer: newElements,
@@ -749,7 +749,7 @@ extension RigidArray {
>(
removing subrange: Range<Int>,
copying newElements: C
) {
) where C.Failure == Never {
_replace(
removing: subrange,
copyingContainer: newElements,
@@ -119,7 +119,7 @@ extension RigidSet /* where Element: Copyable */ {
@_alwaysEmitIntoClient
@inline(__always)
public init<
S: Iterable_<Element> & Sequence<Element>
S: Iterable_<Element, Never> & Sequence<Element>
>(
capacity: Int,
copying contents: borrowing S
@@ -131,7 +131,7 @@ extension RigidSet /* where Element: Copyable */ {
@_alwaysEmitIntoClient
@inline(__always)
public init<
S: Iterable_<Element> & Collection<Element>
S: Iterable_<Element, Never> & Collection<Element>
>(
capacity: Int? = nil,
copying contents: S
@@ -261,7 +261,7 @@ extension RigidSet /* where Element: Copyable */ {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
S: Iterable_<Element> & Sequence<Element>
S: Iterable_<Element, Never> & Sequence<Element>
>(
copying items: borrowing S
) {
@@ -310,14 +310,14 @@ extension UniqueArray {
#if compiler(>=6.4) && UnstableContainersPreview
@inlinable
internal mutating func _append<
Source: Iterable_<Element> & ~Copyable & ~Escapable
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
>(
copying newElements: borrowing Source
) {
) throws(E) {
_ensureFreeCapacity(newElements.underestimatedCount_)
var it = newElements.makeIterableIterator_()
while true {
let span = it.nextSpan_()
let span = try it.nextSpan_()
if span.isEmpty { break }
_ensureFreeCapacity(span.count)
_storage.append(copying: span)
@@ -343,11 +343,11 @@ extension UniqueArray {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
Source: Iterable_<Element> & ~Copyable & ~Escapable
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
>(
copying newElements: borrowing Source
) {
self._append(copying: newElements)
) throws(E) {
try self._append(copying: newElements)
}
#endif
@@ -397,7 +397,7 @@ extension UniqueArray {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
Source: Iterable_<Element> & Sequence<Element>
Source: Iterable_<Element, Never> & Sequence<Element>
>(copying newElements: Source) {
self._append(copying: newElements)
}
@@ -96,12 +96,12 @@ extension UniqueArray /*where Element: Copyable*/ {
/// The sequence must not contain more than `capacity` elements.
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_<Element> & ~Copyable & ~Escapable>(
public init<Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E>(
capacity: Int? = nil,
copying contents: borrowing Source
) {
) throws(E) {
self.init(minimumCapacity: capacity ?? 0)
self.append(copying: contents)
try self.append(copying: contents)
}
#endif
@@ -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: Iterable_<Element> & Sequence<Element>>(
public init<Source: Iterable_<Element, Never> & Sequence<Element>>(
capacity: Int? = nil,
copying contents: Source
) {
@@ -396,7 +396,7 @@ extension UniqueArray {
C: Container<Element> & ~Copyable & ~Escapable
>(
copying newElements: borrowing C, at index: Int
) {
) where C.Failure == Never {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c)
@@ -463,7 +463,7 @@ extension UniqueArray {
C: Container<Element> & Collection<Element>
>(
copying newElements: borrowing C, at index: Int
) {
) where C.Failure == Never {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c)
@@ -558,7 +558,7 @@ extension UniqueArray {
>(
removing subrange: Range<Int>,
copying newElements: borrowing C
) {
) where C.Failure == Never {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c - subrange.count)
@@ -648,7 +648,7 @@ extension UniqueArray {
>(
removing subrange: Range<Int>,
copying newElements: borrowing C
) {
) where C.Failure == Never {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c - subrange.count)
@@ -95,7 +95,7 @@ extension UniqueSet where Element: Copyable {
#if UnstableContainersPreview
@_alwaysEmitIntoClient
public init<
S: Iterable_<Element> & Sequence<Element>
S: Iterable_<Element, Never> & Sequence<Element>
>(
copying items: borrowing S
) {
@@ -172,7 +172,7 @@ extension UniqueSet /* where Element: Copyable */ {
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
S: Iterable_<Element> & Sequence<Element>
S: Iterable_<Element, Never> & Sequence<Element>
>(
copying items: borrowing S
) {