-
Hello, I am somewhat of an amateur when it comes to Rust (especially asynchronous programming in it). I am trying to find out a way to see if a task I spawned is still running after a loop so that I can cancel it. The only solution that made sense to me at my skill level was to make a Vector that holds all of the spawned tasks, and then check the vector to see if the tasks are still running. But this led to a bizarre problem that I cannot find a solution for anywhere. I have the following code that is giving me an error:
The error goes as follows:
Line 1006 goes as follows:
The update_tags function in the api module is defined as follows:
My main() function is defined as follows:
I cannot post the full code unfortunately, but I was hoping that someone could help give me an idea of what was going on because I am very confused. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I tried to define the type of the Vector with the following code:
But I get the error:
Now I understand that this is because the type inside JoinHandle isn't known (the <_> portion). Does anyone know if there is any type I can put inside there that would fix my issue? The code I am trying to store inside this vec goes as follows:
I appreciate the help. |
Beta Was this translation helpful? Give feedback.
-
It seems like you aren't returning anything from the task, in which case the return type is I note that this error sometimes comes from another error inhibiting type inference. If there are also other errors, you may want to try and fix those first. You may find this page on graceful shutdown useful. |
Beta Was this translation helpful? Give feedback.
It seems like you aren't returning anything from the task, in which case the return type is
()
. In that case, you would useJoinHandle<()>
as the type.I note that this error sometimes comes from another error inhibiting type inference. If there are also other errors, you may want to try and fix those first.
You may find this page on graceful shutdown useful.