Winter maybe-async
This crate contains a maybe_async proc macro that abstracts away sync/async. It is heavily based on maybe-async.
The maybe_async macro will generate a synchronous or asynchronous version of the trait it is marking. To generate the asynchronous version, enable the async feature on the crate. If the async feature is off, the synchronous version will be generated. For example,
// Generate code when `async` feature is turned ON
// Generate code when `async` feature is turned OFF
where #[async_trait] is the proc macro provided by the async-trait crate. Notice how #[maybe_async] took care of removing the .await in the synchronous version of say_hello().
#[maybe_async] can also mark impl blocks in a similar manner. For example,
;
// Generate code when `async` feature is turned ON
// Generate code when `async` feature is turned OFF
Finally, #[maybe_async] can be used on fn items, which works in an analogous way to the previous examples.
async
License
This project is MIT licensed.