Skip to content

Is there something like join_any? #4708

Answered by Darksonn
lz1998 asked this question in Q&A
Discussion options

You must be logged in to vote

Use a pattern to disable the tokio::select! branch if it returns an error.

async fn connect(&self, _: &Arc<Client>) -> std::io::Result<TcpStream> {
    tokio::select! {
        Ok(conn1) = connect1() => Ok(conn1),
        Ok(conn2) = connect2() => Ok(conn2),
        else => Err(...)
    }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lz1998
Comment options

@Darksonn
Comment options

Answer selected by lz1998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants