Hello there,
is there a way to either convert a Future<Item=Vec<T>, Error=E>
into a Stream or to run a for_each()
command on a future of a Vec<T>
?
I'm trying to write something more elegant than
futures::future::ok(vec![1,2,3])
.map(|vec| {
vec.iter().for_each(some_fn);
Ok(())
})
Thanks in advance
kornel
November 12, 2018, 2:29pm
2
If it's a vec of regular items, not a vec of futures, then mixing it with the future-spawning machinery is entirely unnecessary.
Your code seems fine. If you use this pattern a lot, you can make your own trait with a helper method.
No it's actually deep within a chain of futures that one future is returning a Vec<T>
. I started by chaining with a for_each()
and was surprised to see the compiler returning an error