You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use async_recursion::async_recursion;#[tokio::main]asyncfnmain(){count_down(5,None).await;}#[async_recursion]asyncfncount_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.
The text was updated successfully, but these errors were encountered:
Hello,
I am wondering how to deal with this situation.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9c9d1ddc0b3ece4b4bb40280c0fda6ca
Output:
The "help" given by rustc is invalid.
The text was updated successfully, but these errors were encountered: