Hopefully this specific invocation wasn't part of your goals:
futures::executor::block_on(my_callback.call_it(value, value.as_ref()));
// ^^^^^^^^^^^^^^^^^^^^^
Because you can't pass something that isn't Copy by value and by reference at the same time.
Otherwise, the problem in the code is similar to this recent thread: A cannot represent a borrow-capturing return type, and you need it to.
impl<T, F, A> Callback<T> for F
where
T: Foo,
// This can't accept functions that return futures that capture the
// lifetime here ---vv
F: FnOnce(T, T::Bar<'_>) -> A,
A: Future<Output = ()>
async fn returns and -> impl ... capture all generics in scope, and your bound is short for:
F: for<'any> FnOnce(T, T::Bar<'any>) -> A
Unlike the other thread, at least in this example, you don't need more bounds on the future. So AsyncFnOnce can solve the playground.
impl<T, F> Callback<T> for F
where
T: Foo,
F: AsyncFnOnce(T, T::Bar<'_>),
{
In slightly different circumstances, an alternative might have been to accept a single lifetime for the T::Bar<'_> argument to the closure. But being the associated type rules that out (I think), and besides, that also changes the semantics (you can't pass in local borrows to the closure if you do that).