cgp_async_macro/lib.rs
1#![no_std]
2
3/*!
4   This library provides helper macros for using async functions in traits.
5*/
6
7extern crate alloc;
8extern crate proc_macro;
9
10use proc_macro::TokenStream;
11
12mod impl_async;
13mod strip_async;
14
15/**
16   This macro can be used in place of the [`macro@native_async`] macro
17   to strip away all use of `async` and `.await` syntax. This helps emulate
18   async-generic by turnining async functions into sync functions.
19*/
20#[proc_macro_attribute]
21pub fn strip_async(_attr: TokenStream, stream: TokenStream) -> TokenStream {
22    strip_async::strip_async(stream.into()).into()
23}
24
25#[proc_macro_attribute]
26pub fn native_async(_attr: TokenStream, stream: TokenStream) -> TokenStream {
27    impl_async::impl_async(stream.into()).into()
28}