DEV Community


Discussion on: Are async frameworks really worth it?

idanarye profile image
Idan Arye

In your example though, I don't see why you couldn't just make the connection vector hold a type parameter and add the second request with another type.

You mean something like this?

fn next_available() -> (usize, i64) {
    for (i, (orig_index, request)) in remaining_requests.iter().enumerate() {
        if Some(response) = request.try_read() {
            return Some((orig_index, match request {
                FirstRequest(..) => FirstResponse(response),
                SecondRequest(..) => SecondResponse(response),

if let Some(i, response) = next_available() {
    match response {
        FirstResponse(response) => {
        SecondResponse(response) {
            result[i] =;

It doesn't scale very well:

  • You need, for each IO in the algorithm, to add a branch to the enum.
  • Code sequence that normally goes together needs to be broken to different places.
  • If you want to add other algorithms on the same loop, it's hard to keep them from tangling with each other.
Thread Thread
legolord208 profile image
jD91mZM2 Author

Alright. Thanks for a nice discussion!

Forem Open with the Forem app