Macro content

Source
content!() { /* proc-macro */ }
Expand description

A wrapper for code with common maybe parameters

The content macro allows you to specify common parameters for many maybe macros. Use the internal default attribute with the required parameters inside the content macro.

maybe_async_cfg::content!{
#![maybe_async_cfg::default(
    idents(Foo, Bar),
)]

#[maybe_async_cfg::maybe(sync(feature="use_sync"), async(feature="use_async"))]
struct Struct {
    f: Foo,
}

#[maybe_async_cfg::maybe(sync(feature="use_sync"), async(feature="use_async"))]
async fn func(b: Bar) {
    todo!()
}
} // content!

After conversion:

#[cfg(feature="use_sync")]
struct StructSync {
    f: FooSync,
}
#[cfg(feature="use_async")]
struct StructAsync {
    f: FooAsync,
}

#[cfg(feature="use_sync")]
fn func_sync(b: BarSync) {
    todo!()
}
#[cfg(feature="use_async")]
async fn func_async(b: BarAsync) {
    todo!()
}