error: lifetime may not live long enough
--> src/main.rs:2:16
|
2 | |i: &i32| async move { i; true };
| - - ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure `impl Future` contains a lifetime `'2`
| let's call the lifetime of this reference `'1`
What is the difference between the two? Why closure type is inferred as for<'1, '2> &'1 i32 -> impl Future + '2, while the async fn type is infered to be for<'1> &'1 i32 -> impl Future + '1?
P.S.: I know that I can copy i before async block, but it's just an MRE of the problem
P.P.S.: This came out while trying to make async guard fns work, a more real-life example in this playground.