How May handles coroutines

The Rust ecosystem has a number of coroutine implementations, while the core team is working on in-language implementations. Of these, one of the widely used is called May, which is a standalone stackful coroutine library based on generators. May strives to be user-friendly enough so that a function can be asynchronously invoked using a simple macro that takes in the function. In feature parity with the Go programming language, this macro is called go!. Let's look at a small example of using May.

We will use our good ol' friend, Collatz sequence, for this example; this will show us multiple ways of achieving the same goal. Let's start with setting up our project using Cargo:

[package]name = "collatz-may"version ...

Get Network Programming with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.