Make Asynchronous wrapper function

Here is a playground of my problem and I am getting many lifetime errors.

In reality, the wrapper function is creating a new struct that depends on the string, and passes it to the callback; I am doing this to avoid the hassle of self-referential structs. Is there any way I can achieve this?

Edit: I forgot to mention that to_owned in reality is an async function.

The Fut type returned by your FnOnce does not depend on the lifetime you introduced with for<'a>, so it cannot borrow from the parameter you marked with 'a. If you can't avoid moving a borrow into the async block, there is no easy fix.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.