mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Review error handling
This commit is contained in:
16 files changed
+148
-126
No files matched your search
@@ -349,10 +349,11 @@ extension RigidArray {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _append<
|
||||
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
|
||||
Source: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
let target = _freeSpace
|
||||
_count += try newElements._copyContents(intoPrefixOf: target)
|
||||
}
|
||||
@@ -371,10 +372,11 @@ extension RigidArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
|
||||
Source: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
try _append(copying: newElements)
|
||||
}
|
||||
#endif
|
||||
@@ -413,9 +415,12 @@ extension RigidArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: Iterable_<Element, Never> & Sequence<Element>
|
||||
>(copying newElements: Source) {
|
||||
_append(copying: newElements)
|
||||
Source: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
copying newElements: Source
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
try _append(copying: newElements)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -124,10 +124,11 @@ extension RigidArray /*where Element: Copyable*/ {
|
||||
/// The container must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E>(
|
||||
public init<Source: Iterable_ & ~Copyable & ~Escapable>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
self.init(capacity: capacity)
|
||||
try self.append(copying: contents)
|
||||
}
|
||||
@@ -145,12 +146,13 @@ extension RigidArray /*where Element: Copyable*/ {
|
||||
/// The container must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: Iterable_<Element, Never> & Sequence<Element>>(
|
||||
public init<Source: Iterable_ & Sequence<Element>>(
|
||||
capacity: Int,
|
||||
copying contents: Source
|
||||
) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
self.init(capacity: capacity)
|
||||
self.append(copying: contents)
|
||||
try self.append(copying: contents)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,25 +120,27 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: Iterable_<Element, Never> & Sequence<Element>
|
||||
S: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
capacity: Int,
|
||||
copying contents: borrowing S
|
||||
) {
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
self.init(capacity: capacity)
|
||||
self._insert(copying: contents)
|
||||
try self._insert(copying: contents)
|
||||
}
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<
|
||||
S: Iterable_<Element, Never> & Collection<Element>
|
||||
S: Iterable_ & Collection<Element>
|
||||
>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: S
|
||||
) {
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
self.init(capacity: capacity ?? contents.count)
|
||||
self._insert(copying: contents)
|
||||
try self._insert(copying: contents)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -223,11 +223,11 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
package mutating func _insert<
|
||||
Failure: Error,
|
||||
S: Iterable_<Element, Failure> & ~Copyable & ~Escapable
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_) {
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
var it = items.makeIterableIterator_()
|
||||
while true {
|
||||
let span = try it.nextSpan_()
|
||||
@@ -263,11 +263,12 @@ extension RigidSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: Iterable_<Element, Never> & Sequence<Element>
|
||||
S: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
_insert(copying: items)
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
try _insert(copying: items)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -310,10 +310,11 @@ extension UniqueArray {
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@inlinable
|
||||
internal mutating func _append<
|
||||
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
|
||||
Source: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
_ensureFreeCapacity(newElements.underestimatedCount_)
|
||||
var it = newElements.makeIterableIterator_()
|
||||
while true {
|
||||
@@ -343,10 +344,11 @@ extension UniqueArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E
|
||||
Source: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying newElements: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
try self._append(copying: newElements)
|
||||
}
|
||||
|
||||
@@ -397,9 +399,12 @@ extension UniqueArray {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append<
|
||||
Source: Iterable_<Element, Never> & Sequence<Element>
|
||||
>(copying newElements: Source) {
|
||||
self._append(copying: newElements)
|
||||
Source: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
copying newElements: Source
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
try self._append(copying: newElements)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ extension UniqueArray /*where Element: Copyable*/ {
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: Iterable_<Element, E> & ~Copyable & ~Escapable, E>(
|
||||
public init<Source: Iterable_ & ~Copyable & ~Escapable>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: borrowing Source
|
||||
) throws(E) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
self.init(minimumCapacity: capacity ?? 0)
|
||||
try self.append(copying: contents)
|
||||
}
|
||||
@@ -132,12 +133,13 @@ extension UniqueArray /*where Element: Copyable*/ {
|
||||
/// - contents: The container whose contents to copy into the new array.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<Source: Iterable_<Element, Never> & Sequence<Element>>(
|
||||
public init<Source: Iterable_ & Sequence<Element>>(
|
||||
capacity: Int? = nil,
|
||||
copying contents: Source
|
||||
) {
|
||||
) throws(Source.Failure_)
|
||||
where Source.Element_ == Element {
|
||||
self.init(minimumCapacity: capacity ?? 0)
|
||||
self.append(copying: contents)
|
||||
try self.append(copying: contents)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -96,12 +96,13 @@ extension UniqueSet where Element: Copyable {
|
||||
#if UnstableContainersPreview
|
||||
@_alwaysEmitIntoClient
|
||||
public init<
|
||||
S: Iterable_<Element, Never> & Sequence<Element>
|
||||
S: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
self.init()
|
||||
self._insert(copying: items)
|
||||
try self._insert(copying: items)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -173,11 +173,12 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: Iterable_<Element, Never> & Sequence<Element>
|
||||
S: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) {
|
||||
_insert(copying: items)
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
try _insert(copying: items)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user