-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
Hello,
I am wondering how to deal with this situation.
use async_recursion::async_recursion;
#[tokio::main]
async fn main() {
count_down(5, None).await;
}
#[async_recursion]
async fn count_down(num: u32, foo: Option<&str>) {
if num == 0 {
return;
}
println!("{}, {:?}", num, foo);
count_down(num - 1, foo);
}Output:
error: lifetime may not live long enough
--> src/main.rs:8:1
|
8 | #[async_recursion]
| ^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
9 | async fn count_down(num: u32, foo: Option<&str>) {
| - let's call the lifetime of this reference `'1`
|
= note: this error originates in the attribute macro `async_recursion` (in Nightly builds, run with -Z macro-backtrace for more info)
help: to declare that the trait object captures data from argument `foo`, you can add an explicit `'_` lifetime bound
|
8 | #[async_recursion] + '_
| ++++
The "help" given by rustc is invalid.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels