pub trait AssertSend: Future {
// Provided method
fn send(self) -> impl Future<Output = Self::Output> + Send
where Self: Sized + Send { ... }
}Expand description
If your future is not Send enough, try this.
Async functions (i.e., those with the keyword async) rely on type inference to
automatically derive Send and Sync bounds for the returned Futures. Unfortunately,
rustc seems to throw away quite a bit of information when building large futures like
we have in diskann_async, which can result in large futures failing to be Send
due to the bound on an inner Future being forgotten.
The AssertSend is a hack that helps rustc realize that interior Futures are
indeed Send and helps when proving the auto trait for larger Futures.
This is mainly helpful when async functions take closures.