Is it possible to join 2 futures in spawning task? #4378
Answered
by
Darksonn
liang-kang
asked this question in
Q&A
-
Here is the sample code:
such code will cause the compiling error:
If replacing join! macro with f1.await and f2.await, there will be no such compiling issue. |
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
Jan 5, 2022
Replies: 1 comment 1 reply
-
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 let f2 = async move {
let file = tokio::fs::File::open("test.rs").await?;
myfile.read_buf(c2_ref).await
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
liang-kang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.