futures-rs icon indicating copy to clipboard operation
futures-rs copied to clipboard

Async transformations on arrays

Open segeljakt opened this issue 2 years ago • 0 comments

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);

segeljakt avatar Dec 12 '22 17:12 segeljakt