The following code fails with
cannot move out of `my_number_vector`, a captured variable in an `FnMut` closure
move out of `my_number_vector`
[dependencies]
futures = "0.3.21"
tokio = "1.19.2"
use futures::{stream, StreamExt};
#[tokio::main]
async fn main() {
let mut my_number_vector = Vec::new();
let the_stream = stream::iter(0..=10);
let response_of_stream = stream_of_urls
.map(|number| async move {
number
})
.buffer_unordered(2);
response_of_stream
.for_each(|number| async move {
my_number_vector.push(number);
})
.await;
}
How is it possible to append to a vector in this scenario? I tried using RC and RefCells but it seems I cannot understand the error accurately in order to solve the compiler error.