Right now, I’m going for a library-based approach that works on stable, so I have a trait with an
execute() method that returns an
enum with variants for completion, non-blocking yield, and blocking yield (and maybe errors too in the future, still need to figure out if I need it or if it can be bundled with another outcome).
In a way, that’s similar to the Future trait, but not quite it because 1/I do not return results at the end and 2/I can yield without blocking.
But this library-based approach does not allow borrowing across yield points, which leads to the well-known usability problems of manual futures without
async fn (need to put everything in
Arc, etc.). So if I switched to nightly, I would use generators instead, which IIRC address this problem now.
My general point of view is that working with nightly is a bit of a pain because of the periodic breakages, so I avoid doing so at this early research stage. Hopefully, by the time where I’ll really want generators, they will finally have landed on stable.