Attribute Macro openraft::add_async_trait
source · #[add_async_trait]
Expand description
This proc macro attribute optionally adds Send
bounds to a trait.
By default, Send
bounds will be added to the trait and to the return bounds of any async
functions defined within the trait.
If the singlethreaded
feature is enabled, the trait definition remains the same without any
added Send
bounds.
§Example
use openraft_macros::add_async_trait;
#[add_async_trait]
trait MyTrait {
async fn my_method(&self) -> Result<(), String>;
}
The above code will be transformed into:
ⓘ
trait MyTrait {
fn my_method(&self) -> impl Future<Output=Result<(), String>> + Send;
}
Note: This proc macro can only be used with traits.
§Panics
This proc macro will panic if used on anything other than trait definitions.