Save code duplication when writing very similar sync and async functions.
| src | fix: panic if >3 pre-attributes | |
| tests | feat: first version | |
| .gitignore | feat: first version | |
| Cargo.lock | feat: first version | |
| Cargo.toml | feat: first version | |
| LICENSE | chore: add license | |
| README.md | doc: added similar crates | |
| TODO.md | chore: add license | |
Excerpts from the crate's documentation
Save code duplication when writing very similar sync and async functions. This is all done via
the [asyncator] macro.
Examples
useasyncator::asyncator;#[asyncator]#[name_sync(function_sync)]asyncfn function_async()-> &'static str {#[cfg_sync]return"Hello world";#[cfg_async]async{"Hello world"}.await}expands to
fn function_sync()-> &'static str {return"Hello world";}asyncfn function_async()-> &'static str {async{"Hello world"}.await}Usage to gate a blocking API behind a feature
useasyncator::asyncator;#[asyncator]#[name_sync(my_function_blocking)]#[cfg_sync(feature = "blocking")]// So it's always included
#[cfg_async(true)]fn my_function(){}More info in this crate documentation, but since I am not on crates.io there is
no proper way to see it, save for cloning this repo and running cargo doc (or
you can read the doc in the code)
As a result of not being on crates.io, if you want to add asyncator as a dependency, see the official doc
Similar crates: