Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/07_workarounds/05_recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,19 @@ to make `recursive` into a non-`async` function which returns a `.boxed()`
```rust,edition2018
{{#include ../../examples/07_05_recursion/src/lib.rs:example}}
```

## Using a Macro

There is also a community-developed macro, [`async-recursion`](https://github.com/dcchut/async-recursion), that can be used to automatically transform an async function to return a boxed future:

```rust
use async_recursion::async_recursion;

#[async_recursion]
async fn recursive() {
recursive().await;
recursive().await;
}
```

This allows the function to recurse without you having to manually change the method signature and body.