let fu1 = async block { /* ... */ };
let fu2 = async block { /* ... */ };
let fu3 = async block { /* ... */ };
I want to push them into futures::stream::futures_unordered::FuturesUnordered without Box<T> or heap allocation. How should I declare the T of FuturesUnordered<T> in my struct?
I tried to store futures::future::lazy, that does not compile.
I don't think this is possible, unless your FuturesUnordered stream is outlived by your futures, then you can take them by &mut dyn Future<Output = ()>.
But why is allocation so forbidden? FuturesUnordered itself allocates, BTW.
But really dislike Box<T> since it cause extra heap allocation. As I understand, the size of the future is known at compile time, right? can I somehow get rid of the Box?
In this case the problem is your use of generics. With generics I might decide to construct a XXXXXXXX<std::future::Pending> and then your own async fn won't be of the right type. You can't do it if it is to be stored as a field in a struct.