For some reason FnMutFut<&'any BAZ::Param, ()> is not being inferred as FnMutFut<&'any i32, ()>, which results in an unsatisfied trait bound error.
use std::future::Future;
pub trait Baz {
type Param;
}
pub trait FnMutFut<P, R>: FnMut(P) -> Self::Future {
type Future: Future<Output = R>;
}
impl<P, F, FUT, R> FnMutFut<P, R> for F
where
F: FnMut(P) -> FUT,
FUT: Future<Output = R>,
{
type Future = FUT;
}
pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
where
BAZ: Baz<Param = i32>,
{
cb(&1i32).await;
}
Perhaps something involving the generic implementation of FnMutFut? Perhaps something involving impl trait?
For some reason
FnMutFut<&'any BAZ::Param, ()>is not being inferred asFnMutFut<&'any i32, ()>, which results in an unsatisfied trait bound error.Perhaps something involving the generic implementation of
FnMutFut? Perhaps something involvingimpl trait?