Closed
Description
We should suggest the use of https://docs.rs/async-recursion/0.3.2/async_recursion/ when writing
async fn fib(n : u32) -> u64 {
match n {
0 => panic!("zero is not a valid argument to fib()!"),
1 | 2 => 1,
3 => 2,
_ => fib(n-1).await + fib(n-2).await
}
}
error[E0733]: recursion in an `async fn` requires boxing
--> src/lib.rs:1:26
|
1 | async fn fib(n : u32) -> u64 {
| ^^^ recursive `async fn`
|
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`