I want to do the following
struct Stored<F: Future<Output = ()>> {
f: Option<F>,
}
impl<F: Future<Output = ()>> Stored<F> {
fn store(&mut self, f: F) {
let f = async {};
self.f = Some(f);
}
}
But it gives me the error:
expected type parameter `F`
found opaque type `impl futures::Future<Output = ()>`
type parameters must be constrained to match other types
I could solve it boxing the future, but if the method store
was the only place I stored this future, there would be no need to do that, because all the future blocks would be always the same type. How could I do it?