[ContainersPreview] Audit some protocol extensions for SuppressedAssociatedTypesWithDefaults

This commit is contained in:
Karoy Lorentey committed 2026-03-26 16:05:07 -07:00
1 parent e2b980a4cc
commit eb708a9ba5
27 files changed
+158 -67

No files matched your search

@@ -18,7 +18,11 @@ import InternalCollectionsUtilities
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: Equatable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable, Element: Equatable,
Element: ~Copyable
{
@inlinable
package func _elementsEqual<
Other: BorrowingSequence<Element> & ~Copyable & ~Escapable
@@ -32,7 +36,11 @@ extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: Equatab
}
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
/// Returns a Boolean value indicating whether two borrowing sequences contain
/// equivalent elements in the same order, using the given predicate as the
/// equivalence test.
@@ -72,7 +80,7 @@ extension BorrowingSequence where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: Equatable
Element: ~Copyable & Equatable
{
@inlinable
package consuming func elementsEqual<
@@ -159,7 +167,11 @@ where
}
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
package consuming func elementsEqual<
E: Error,
@@ -14,7 +14,11 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
@_lifetime(copy self)
public consuming func filter(
@@ -26,8 +30,9 @@ extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
@available(SwiftStdlib 5.0, *)
public struct BorrowingFilter<
Base: BorrowingIteratorProtocol & ~Copyable & ~Escapable,
>: ~Copyable, ~Escapable {
Base: BorrowingIteratorProtocol & ~Copyable & ~Escapable
>: ~Copyable, ~Escapable
where Base.Element: ~Copyable {
public typealias Element = Base.Element
@_alwaysEmitIntoClient
@@ -51,7 +56,7 @@ public struct BorrowingFilter<
@available(SwiftStdlib 5.0, *)
extension BorrowingFilter: BorrowingIteratorProtocol
where Base: ~Copyable & ~Escapable {
where Base: ~Copyable & ~Escapable, Base.Element: ~Copyable {
@_lifetime(&self)
public mutating func nextSpan(maximumCount: Int) -> Span<Element> {
// FIXME: This is quite inefficient compared to Container's filter
@@ -14,7 +14,11 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
@_lifetime(copy self)
public consuming func map<E: Error, T: ~Copyable>(
@@ -14,7 +14,11 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
public consuming func reduce<Result: ~Copyable, E: Error>(
_ initialResult: consuming Result,
@@ -18,7 +18,11 @@ import InternalCollectionsUtilities
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable {
extension BorrowingIteratorProtocol
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
internal consuming func _spanwiseZip<
Other: BorrowingIteratorProtocol & ~Copyable & ~Escapable,
@@ -96,7 +96,8 @@ public protocol BorrowingIteratorProtocol<Element>: ~Copyable, ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, Element: ~Copyable {
extension BorrowingIteratorProtocol
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_lifetime(&self)
@_lifetime(self: copy self)
@_transparent
@@ -106,7 +107,8 @@ extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, Element:
}
@available(SwiftStdlib 5.0, *)
extension BorrowingIteratorProtocol where Self: ~Copyable & ~Escapable, Element: ~Copyable {
extension BorrowingIteratorProtocol
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_lifetime(self: copy self)
@inlinable
public mutating func skip(by offset: Int) -> Int {
@@ -14,7 +14,11 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: ~Copyable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
public func reduce<Result: ~Copyable>(
_ initialResult: consuming Result,
@@ -45,12 +49,18 @@ extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: ~Copyab
}
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: ~Copyable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
public func elementsEqual<OtherSequence: BorrowingSequence>(
_ other: borrowing OtherSequence,
by areEquivalent: (borrowing Element, borrowing OtherSequence.Element) throws -> Bool
) rethrows -> Bool where OtherSequence: ~Copyable & ~Escapable, OtherSequence.Element: ~Copyable {
) rethrows -> Bool
where OtherSequence: ~Copyable & ~Escapable, OtherSequence.Element: ~Copyable
{
var iter1 = makeBorrowingIterator()
var iter2 = other.makeBorrowingIterator()
while true {
@@ -75,7 +85,8 @@ extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: ~Copyab
}
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable, Element: ~Copyable & Equatable {
extension BorrowingSequence
where Self: ~Copyable & ~Escapable, Element: ~Copyable & Equatable {
@inlinable
public func elementsEqual<OtherSequence: BorrowingSequence<Element>>(
_ other: borrowing OtherSequence
@@ -29,7 +29,10 @@ public protocol BorrowingSequence<Element>: ~Copyable, ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
public var underestimatedCount: Int { 0 }
@@ -48,7 +51,11 @@ extension BorrowingSequence where Self: Sequence {
}
@available(SwiftStdlib 5.0, *)
extension BorrowingSequence where Self: ~Copyable & ~Escapable {
extension BorrowingSequence
where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
/// Implementation demo of what borrowing for-in loops would need to expand into.
@inlinable
public func _borrowingForEach<E: Error>(
@@ -14,7 +14,9 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
public protocol BidirectionalContainer<Element>: Container, ~Copyable, ~Escapable {
public protocol BidirectionalContainer<Element>: Container, ~Copyable, ~Escapable
where Element: ~Copyable
{
func index(before i: Index) -> Index
func formIndex(before i: inout Index)
@@ -24,7 +26,8 @@ public protocol BidirectionalContainer<Element>: Container, ~Copyable, ~Escapabl
}
@available(SwiftStdlib 5.0, *)
extension BidirectionalContainer where Self: ~Copyable & ~Escapable {
extension BidirectionalContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public func formIndex(before i: inout Index) {
i = self.index(before: i)
@@ -18,7 +18,7 @@ import InternalCollectionsUtilities
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable /*& ~Escapable*/ {
extension Container where Self: ~Copyable /*& ~Escapable*/, Element: ~Copyable {
@_lifetime(borrow self)
public func _filter(
_ isIncluded: @escaping (borrowing Element) -> Bool
@@ -28,7 +28,7 @@ extension Container where Self: ~Copyable /*& ~Escapable*/ {
}
@available(SwiftStdlib 5.0, *)
extension ContainerIterator {
extension ContainerIterator where Base.Element: ~Copyable {
@_lifetime(copy self)
public func filter(
_ isIncluded: @escaping (borrowing Element) -> Bool
@@ -40,7 +40,9 @@ extension ContainerIterator {
@available(SwiftStdlib 5.0, *)
public struct ContainerFilter<
Base: Container & ~Copyable/* FIXME & ~Escapable */
>: ~Copyable, ~Escapable {
>: ~Copyable, ~Escapable
where Base.Element: ~Copyable
{
public typealias Element = Base.Element
@_alwaysEmitIntoClient
@@ -84,7 +86,7 @@ public struct ContainerFilter<
// FIXME: Sendable
@available(SwiftStdlib 5.0, *)
extension ContainerFilter: BorrowingIteratorProtocol {
extension ContainerFilter: BorrowingIteratorProtocol where Element: ~Copyable {
@_lifetime(copy self)
public mutating func nextSpan(maximumCount: Int) -> Span<Element> {
precondition(maximumCount > 0)
@@ -18,7 +18,7 @@ import InternalCollectionsUtilities
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 6.2, *)
extension Container where Self: ~Copyable & ~Escapable {
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_alwaysEmitIntoClient
internal func _spanwiseZip<Other: Container & ~Copyable & ~Escapable, E: Error>(
with other: borrowing Other,
@@ -14,7 +14,9 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
public protocol Container<Element>: BorrowingSequence, ~Copyable, ~Escapable {
public protocol Container<Element>: BorrowingSequence, ~Copyable, ~Escapable
where Element: ~Copyable
{
associatedtype Index: Comparable
// FIXME: Ideally Index should also be required to be Hashable.
// FIXME: If we discard the separate BorrowingSequence abstraction, then we
@@ -168,7 +170,7 @@ public protocol Container<Element>: BorrowingSequence, ~Copyable, ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable {
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// Return a span over the container's storage that begins with the element at
/// the given index, and extends to the end of the contiguous storage chunk
/// that contains it. On return, the index is updated to address the next item
@@ -224,7 +226,7 @@ extension Container where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable {
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public func formIndex(after index: inout Index) {
index = self.index(after: index)
@@ -256,7 +258,7 @@ extension Container where Self: ~Copyable & ~Escapable {
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable {
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public func _defaultDistance(from start: Index, to end: Index) -> Int {
// FIXME: Use binary search here (with nextSpan(after:maximumCount:))
@@ -386,7 +388,7 @@ extension Container where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable {
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_transparent
public var underestimatedCount: Int { count }
}
@@ -17,6 +17,7 @@
extension Container
where
Self: ~Copyable /*FIXME: & ~Escapable*/,
Element: ~Copyable,
BorrowingIterator == ContainerIterator<Self>
{
@_lifetime(borrow self)
@@ -28,7 +29,9 @@ where
@available(SwiftStdlib 5.0, *)
public struct ContainerIterator<
Base: Container & ~Copyable /*FIXME: & ~Escapable*/
>: ~Copyable, ~Escapable {
>: ~Copyable, ~Escapable
where Base.Element: ~Copyable
{
let _base: Borrow<Base> // FIXME: This doesn't support nonescapable Bases
var _position: Base.Index
@@ -41,7 +44,9 @@ public struct ContainerIterator<
@available(SwiftStdlib 5.0, *)
extension ContainerIterator: BorrowingIteratorProtocol
where Base: ~Copyable /*FIXME: & ~Escapable*/
where
Base: ~Copyable /*FIXME: & ~Escapable*/,
Base.Element: ~Copyable
{
public typealias Element = Base.Element
@@ -14,7 +14,9 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
public protocol DynamicContainer<Element>: RangeReplaceableContainer, ~Copyable {
public protocol DynamicContainer<Element>: RangeReplaceableContainer, ~Copyable
where Element: ~Copyable
{
init()
init(minimumCapacity: Int)
@@ -24,7 +26,7 @@ public protocol DynamicContainer<Element>: RangeReplaceableContainer, ~Copyable
}
@available(SwiftStdlib 5.0, *)
extension DynamicContainer where Self: ~Copyable {
extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
@inlinable
public init() {
self.init(minimumCapacity: 0)
@@ -14,7 +14,11 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
public protocol MutableContainer<Element>: PermutableContainer, ~Copyable, ~Escapable {
public protocol MutableContainer<Element>:
PermutableContainer, ~Copyable, ~Escapable
where
Element: ~Copyable
{
// subscript(index: Index) -> Element { borrow mutate }
@_lifetime(&self)
@@ -27,7 +31,9 @@ public protocol MutableContainer<Element>: PermutableContainer, ~Copyable, ~Esca
}
@available(SwiftStdlib 5.0, *)
extension MutableContainer where Self: ~Copyable & ~Escapable {
extension MutableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
@_lifetime(&self)
mutating func nextMutableSpan(
@@ -14,7 +14,9 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
public protocol PermutableContainer<Element>: Container, ~Copyable, ~Escapable {
public protocol PermutableContainer<Element>: Container, ~Copyable, ~Escapable
where Element: ~Copyable
{
@_lifetime(self: copy self)
mutating func swapAt(_ i: Index, _ j: Index)
}
@@ -15,7 +15,8 @@
@available(SwiftStdlib 6.2, *)
public protocol RandomAccessContainer<Element>
: BidirectionalContainer, ~Copyable, ~Escapable {}
: BidirectionalContainer, ~Copyable, ~Escapable
where Element: ~Copyable {}
extension RandomAccessCollection {
@inlinable
@@ -21,7 +21,7 @@ public protocol RangeExpression2<Bound> {
func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable
func contains(_ element: Bound) -> Bool
}
@@ -31,7 +31,7 @@ extension Range: RangeExpression2 {
@inlinable
public func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound {
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable {
self
}
}
@@ -41,7 +41,7 @@ extension ClosedRange: RangeExpression2 {
@inlinable
public func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound {
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable {
let end = container.index(after: self.upperBound)
return self.lowerBound ..< end
}
@@ -52,7 +52,7 @@ extension PartialRangeFrom: RangeExpression2 {
@inlinable
public func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound {
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable {
self.lowerBound ..< container.endIndex
}
}
@@ -62,7 +62,7 @@ extension PartialRangeUpTo: RangeExpression2 {
@inlinable
public func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound {
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable {
return container.startIndex ..< self.upperBound
}
}
@@ -72,7 +72,7 @@ extension PartialRangeThrough: RangeExpression2 {
@inlinable
public func relative<C: Container & ~Copyable & ~Escapable>(
to container: borrowing C
) -> Range<Bound> where C.Index == Bound {
) -> Range<Bound> where C.Index == Bound, C.Element: ~Copyable {
let end = container.index(after: self.upperBound)
return container.startIndex ..< end
}
@@ -22,6 +22,7 @@ import InternalCollectionsUtilities
@available(SwiftStdlib 5.0, *)
public protocol RangeReplaceableContainer<Element>
: Container, ~Copyable, ~Escapable
where Element: ~Copyable
{
// Core requirements
@@ -64,7 +65,9 @@ public protocol RangeReplaceableContainer<Element>
//MARK: - Default Implementations
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
public mutating func remove(at index: Index) -> Element {
let range = Range(uncheckedBounds: (index, self.index(after: index)))
@@ -135,7 +138,9 @@ extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
//MARK: - Standard Extensions
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
public mutating func replace<
E: Error,
@@ -202,7 +207,8 @@ extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public mutating func consume(
_ subrange: Range<Index>,
@@ -256,7 +262,8 @@ extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where
Self: BidirectionalContainer,
Self: ~Copyable & ~Escapable
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
@_lifetime(&self)
@@ -272,7 +279,9 @@ where
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
public mutating func removeSubrange(
_ bounds: some RangeExpression2<Index>
@@ -289,7 +298,9 @@ extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
public mutating func insert<
E: Error,
@@ -324,7 +335,8 @@ extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer where Self: ~Copyable & ~Escapable {
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public mutating func append<
E: Error,
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Drain where Self: ~Copyable & ~Escapable {
extension Drain where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
@_lifetime(copy self)
public consuming func map<E: Error, T: ~Copyable>(
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Drain where Self: ~Copyable & ~Escapable {
extension Drain where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public consuming func reduce<Result: ~Copyable, E: Error>(
_ initialResult: consuming Result,
@@ -23,7 +23,7 @@
/// output spans.
@available(SwiftStdlib 5.0, *)
public protocol Drain<Element>: Producer, ~Copyable, ~Escapable
where ProducerError == Never
where Element: ~Copyable, ProducerError == Never
{
/// Returns the next span of consumable items in the sequence underlying this
/// drain, of at most the specified maximum count. A `maximumCount` of nil
@@ -83,7 +83,7 @@ where ProducerError == Never
}
@available(SwiftStdlib 5.0, *)
extension Drain where Self: ~Copyable & ~Escapable {
extension Drain where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// Returns the next span of consumable items in the sequence underlying this
/// drain, of an arbitrarily large count.
///
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public consuming func collect<
R: DynamicContainer<Element> & ~Copyable
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_lifetime(copy self)
public consuming func filter(
// Note: The predicate is not throwing to avoid difficult exception safety problems
@@ -27,7 +27,8 @@ extension Producer where Self: ~Copyable & ~Escapable {
@available(SwiftStdlib 5.0, *)
public struct ConsumingFilterProducer<
Base: Producer & ~Copyable & ~Escapable
>: ~Copyable, ~Escapable {
>: ~Copyable, ~Escapable
where Base.Element: ~Copyable {
public typealias Element = Base.Element
public typealias ProducerError = Base.ProducerError
@@ -55,8 +56,11 @@ where
{}
@available(SwiftStdlib 5.0, *)
extension ConsumingFilterProducer: Producer where Base: ~Copyable & ~Escapable {
extension ConsumingFilterProducer: Producer
where
Base: ~Copyable & ~Escapable,
Base.Element: ~Copyable
{
@inlinable
public var underestimatedCount: Int {
_base.underestimatedCount
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_lifetime(copy self)
public consuming func map<T: ~Copyable>(
_ transform: @escaping (consuming Element) throws(ProducerError) -> T
@@ -27,7 +27,9 @@ extension Producer where Self: ~Copyable & ~Escapable {
public struct ConsumingMapProducer<
Base: Producer & ~Copyable & ~Escapable,
Element: ~Copyable,
>: ~Copyable, ~Escapable {
>: ~Copyable, ~Escapable
where Base.Element: ~Copyable
{
public typealias ProducerError = Base.ProducerError
@_alwaysEmitIntoClient
@@ -51,7 +53,8 @@ extension ConsumingMapProducer: Escapable
where
Element: ~Copyable,
Base: ~Copyable,
Base: Escapable
Base: Escapable,
Base.Element: ~Copyable
{}
@available(SwiftStdlib 5.0, *)
@@ -14,7 +14,7 @@
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
public consuming func reduce<Result: ~Copyable>(
_ initialResult: consuming Result,
@@ -164,7 +164,7 @@ public protocol Producer<Element, ProducerError>: ~Copyable, ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// A value less than or equal to the number of remaining items that this
/// producer is able to generate until it reaches its end.
///
@@ -261,7 +261,7 @@ extension Producer where Self: ~Copyable & ~Escapable {
}
@available(SwiftStdlib 5.0, *)
extension Producer where Self: ~Copyable & ~Escapable {
extension Producer where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// Returns true if the producer has no more elements, consuming it in
/// the process. This is implemented by checking if it is possible to
/// skip one item.