AnyAsyncSequenceable
public struct AnyAsyncSequenceable<Element> : AsyncSequence
extension AnyAsyncSequenceable: AsyncIteratorProtocol
An async sequence that performs type erasure by wrapping another async sequence.
If the async sequence that you wish to type erase can throw, then use AnyThrowingAsyncSequenceable
.
-
Creates a type erasing async sequence.
Declaration
Swift
public init<T>(_ sequence: T) where Element == T.Element, T : AsyncSequence
Parameters
sequence
The async sequence to type erase.
-
Creates an optional type erasing async sequence.
Declaration
Swift
public init?<T>(_ asyncSequence: T?) where Element == T.Element, T : AsyncSequence
Parameters
sequence
An optional async sequence to type erase.
-
Creates an async iterator that emits elements of this async sequence.
Declaration
Swift
public func makeAsyncIterator() -> AnyAsyncSequenceable<Element>
Return Value
An instance that conforms to
AsyncIteratorProtocol
.
-
next()
AsynchronousProduces the next element in the sequence.
Declaration
Swift
public mutating func next() async -> Element?
Return Value
The next element or
nil
if the end of the sequence is reached.