mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-24 04:17:52 +00:00
First pass at some documentation for combineLatest (#94)
* First pass at some documentation for combineLatest * Add additional docs for extension methods and AsyncCombineLatest2Sequence structure
This commit is contained in:
1 parent
f560d1c61f
commit
b11a32fe4e
2 files changed
+8
No files matched your search
@@ -9,10 +9,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Creates an asynchronous sequence that combines the latest values from two `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
public func combineLatest<Base1: AsyncSequence, Base2: AsyncSequence>(_ base1: Base1, _ base2: Base2) -> AsyncCombineLatest2Sequence<Base1, Base2> {
|
||||
AsyncCombineLatest2Sequence(base1, base2)
|
||||
}
|
||||
|
||||
/// An `AsyncSequence` that combines the latest values produced from two asynchronous sequences into an asynchronous sequence of tuples.
|
||||
public struct AsyncCombineLatest2Sequence<Base1: AsyncSequence, Base2: AsyncSequence>: Sendable
|
||||
where
|
||||
Base1: Sendable, Base2: Sendable,
|
||||
@@ -30,6 +33,7 @@ public struct AsyncCombineLatest2Sequence<Base1: AsyncSequence, Base2: AsyncSequ
|
||||
extension AsyncCombineLatest2Sequence: AsyncSequence {
|
||||
public typealias Element = (Base1.Element, Base2.Element)
|
||||
|
||||
/// The iterator for a `AsyncCombineLatest2Sequence` instance.
|
||||
public struct Iterator: AsyncIteratorProtocol, Sendable {
|
||||
enum Partial: Sendable {
|
||||
case first(Result<Base1.Element?, Error>, Base1.AsyncIterator)
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Creates an asynchronous sequence that combines the latest values from three `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
public func combineLatest<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>(_ base1: Base1, _ base2: Base2, _ base3: Base3) -> AsyncCombineLatest3Sequence<Base1, Base2, Base3> {
|
||||
AsyncCombineLatest3Sequence(base1, base2, base3)
|
||||
}
|
||||
|
||||
/// An `AsyncSequence` that combines the latest values produced from three asynchronous sequences into an asynchronous sequence of tuples.
|
||||
public struct AsyncCombineLatest3Sequence<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>: Sendable
|
||||
where
|
||||
Base1: Sendable, Base2: Sendable, Base3: Sendable,
|
||||
@@ -32,6 +35,7 @@ public struct AsyncCombineLatest3Sequence<Base1: AsyncSequence, Base2: AsyncSequ
|
||||
extension AsyncCombineLatest3Sequence: AsyncSequence {
|
||||
public typealias Element = (Base1.Element, Base2.Element, Base3.Element)
|
||||
|
||||
/// The iterator for a `AsyncCombineLatest3Sequence` instance.
|
||||
public struct Iterator: AsyncIteratorProtocol, Sendable {
|
||||
var iterator: AsyncCombineLatest2Sequence<AsyncCombineLatest2Sequence<Base1, Base2>, Base3>.Iterator
|
||||
|
||||
|
||||
Reference in new issue
Block a user