I've been trying to wrap my head around async sequences. While the concept is simple and I think I understand it well, I am specifically struggling with writing some methods that combine and transform sequences. Ideally, I'd like for these methods to support backpressure as well. As an example, I've been trying to implement zip.
Here's an implementation that uses
async let to implement zip: AsyncZipped.swift. When enabling
-Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks, this warns about the iterators not being sendable. So I'm pretty sure my implementation is incorrect.
In my first attempt, I was only able to implement
zip by storing off closures to the
next function of the underlying iterators. While I did get it to compile, this also gives me a bunch of warnings related to
Sendable. (And to be honest, I was surprised it worked at all).
I was wondering if anyone could weigh in whether this approach is futile, or whether it does make sense. My guess is that in order to write
zip, these underlying streams have to be
Sendable? (I'm saying this although I don't fully understand