O'Reilly logo

Network Programming with Rust by Abhishek Chanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required