Skip to content

Is it possible to join 2 futures in spawning task? #4378

Answered by Darksonn
liang-kang asked this question in Q&A
Discussion options

You must be logged in to vote

The error you're getting is one of the few places where the compiler gives a really bad compiler error. I believe there's a bug report for it open already.

Anyway, you should be able to get the error to go away by using an async block instead of and_then.

let f2 = async move {
    let file = tokio::fs::File::open("test.rs").await?;
    myfile.read_buf(c2_ref).await
};

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@liang-kang
Comment options

Answer selected by liang-kang
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