futures-rs
futures-rs copied to clipboard
Question: wait for futures that return no result to complete
I need to perform ~20k API calls. To speed things up I wanted to execute them in parallel + using buffer_unordered
My code looks like this:
pub async fn read() {
let ids: Vec<i32> = (1..20000).collect();
let mut futures = futures::stream::iter(ids)
.map(|id| process_id(id))
.buffer_unordered(15);
// waiting for all to complete
while let Some(_) = futures.next().await {}
}
async fn process_id(id: i32) {
// API call is here
}
Question - is it an idiomatic way to wait for futures that return no result?
I'm referring to this part:
while let Some(_) = futures.next().await {}
Thanks!