Hey there. I was intending to build something like a Makefile clone for myself (a structured task runner) with specific functionalities and I found that first I should build the task runner. I'm more used to writing things in Go, I started doing it there, as the garbage collection would diretly help me just think of the logic. The Go logic was: Each task has a key and a run function, which will be run one in each Go Routine. Each tasks may have dependencies. If task B depends on task A to run, there will be a channel shared between them. When A finishes, it sends a message to that channel. B will be waiting for a message on that channel. Multiple dependencies mean multiple channels for the tasks to wait. One may notice this is a clear Ownership problem: since I am using a map to store the tasks by key, I am mutating 2 different entries of that map at the same time.
Finally, for my question: What am I doing wrong? Is this sort of a "this logic just works in Go because of the language runtime" thing? Or can I do the same thing in Rust, with the same logic?
Go code: https://gist.github.com/FulecoRafa/1b3f80afc282ade3345a1830aef9c9e8
Rust code (or what remains of it after I scrambled it up trying to make it work on my own): https://gist.github.com/FulecoRafa/8b85c5c5d94355385e5f3a7fc40417f9
Thanks in advance! 🙂