I'm looking at this example for concurrently downloading things in Rust.
Roughly, it looks like this:
#![feature(async_closure)]
use futures::{stream, StreamExt}; // 0.3.13
async fn foo() {
let xs_new = stream::once(async { 42 })
.map(async move |x| {
Some(x + 1)
})
.buffer_unordered(42);
}
However, I was hoping to use filter_map
to do something like this:
#![feature(async_closure)]
use futures::{stream, StreamExt}; // 0.3.13
async fn foo() {
let xs_new = stream::once(async { 42 })
.filter_map(async move |x| if x % 2 == 0 { Some(x + 1) } else { None })
.buffer_unordered(42);
}
However this fails with the error: "{integer} is not a Future the trait ... is not implemented for {integer}".
Does anyone know why filter_map
fails but map
works fine?