The naming difficulties were mentioned during the pitch phase.
Would "generator" be a valid alternative to "stream"?
Similar to SE-0300, could the throwing and non-throwing types be combined?
Instead of the nested Termination
enum, could an optional failure type be used?
However, .cancelled
would require Failure == Error
or Failure == CancellationError
.
public struct AsyncGenerator<Element, Failure: Error> {
public struct Continuation: Sendable {
public func yield(_ value: Element)
public func finish(throwing error: Failure? = nil)
public var onTermination: (@Sendable (Failure?) -> Void)? { get nonmutating set }
}
}