From 8ff0e5527d64c58f89c3483416e7a40c43b6cd5e Mon Sep 17 00:00:00 2001 From: Adam Gierscher Date: Tue, 28 Apr 2026 13:13:11 -0400 Subject: [PATCH] Make AsyncShareSequence type Public # Summary Makes the `AsyncShareSequence` type and required protocol conformance public. This allows dependent codebases to store a sequence that has used the `.share()` modifier. # Test Plan - [x] `swift build` succeeds locally --- Sources/AsyncAlgorithms/AsyncShareSequence.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/AsyncAlgorithms/AsyncShareSequence.swift b/Sources/AsyncAlgorithms/AsyncShareSequence.swift index 253edf9e..4b53d3e7 100644 --- a/Sources/AsyncAlgorithms/AsyncShareSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncShareSequence.swift @@ -67,7 +67,7 @@ where Element: Sendable, Self: SendableMetatype, AsyncIterator: SendableMetatype /// public func share( bufferingPolicy: AsyncBufferSequencePolicy = .bounded(1) - ) -> some AsyncSequence & Sendable { + ) -> AsyncShareSequence { // The iterator is transferred to the isolation of the iterating task // this has to be done "unsafely" since we cannot annotate the transfer // however since iterating an AsyncSequence types twice has been defined @@ -115,7 +115,7 @@ where Element: Sendable, Self: SendableMetatype, AsyncIterator: SendableMetatype // This type is typically not used directly; instead, use the `share()` method on any // async sequence that meets the sendability requirements. @available(AsyncAlgorithms 1.1, *) -struct AsyncShareSequence: Sendable +public struct AsyncShareSequence: Sendable where Base.Element: Sendable, Base: SendableMetatype, Base.AsyncIterator: SendableMetatype { // Represents a single consumer's connection to the shared sequence. // @@ -699,26 +699,26 @@ where Base.Element: Sendable, Base: SendableMetatype, Base.AsyncIterator: Sendab @available(AsyncAlgorithms 1.1, *) extension AsyncShareSequence: AsyncSequence { - typealias Element = Base.Element - typealias Failure = Base.Failure + public typealias Element = Base.Element + public typealias Failure = Base.Failure - struct Iterator: AsyncIteratorProtocol { + public struct Iterator: AsyncIteratorProtocol { let side: Side init(_ iteration: Iteration) { side = Side(iteration) } - mutating func next() async rethrows -> Element? { + public mutating func next() async rethrows -> Element? { try await side.next(isolation: nil) } - mutating func next(isolation actor: isolated (any Actor)?) async throws(Failure) -> Element? { + public mutating func next(isolation actor: isolated (any Actor)?) async throws(Failure) -> Element? { try await side.next(isolation: actor) } } - func makeAsyncIterator() -> Iterator { + public func makeAsyncIterator() -> Iterator { Iterator(extent.iteration) } }