1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*!
This library provides helper macros for using async functions in traits.
*/
extern crate alloc;
extern crate proc_macro;
use TokenStream;
/**
The `#[async_trait]` macro is used to desugar async functions in traits
to return `impl Future`.
This macro is required mainly to get around the current limitation of
[async functions in traits](https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits/),
which would produce a lint warning for `async_fn_in_trait` if bare async
functions are defined in a trait.
## Example
Given the following trait definition:
```rust,ignore
#[async_trait]
pub trait CanRun {
async fn run(&self);
}
```
The macro would desugar it to the following:
```rust,ignore
pub trait CanRun {
fn run(&self) -> impl Future<Output = ()>;
}
```
*/