futures-rs
futures-rs copied to clipboard
Async transformations on arrays
Would it be possible to support async transformations on arrays?
async fn map_async<const N: usize, A, B, Fut>(
array: [A;N],
fun: Fn(A) -> Fut
) -> [B;N]
where Fut: Future<Output = B>;
I ran into a case where I'd like to allocate an array of TCP connections.
let sockets = map_async(["127.0.0.1:8000", "127.0.0.1:8001"], connect_socket);
Currently I need to write this in the form of a macro.
let sockets = map_async!(["127.0.0.1:8000", "127.0.0.1:8001"], connect_socket);