I have a set of async tasks where some of them depend on each other, and critically many of them may depend on the same ones. I.e. effectively I have a sort of DAG.
However, to keep the code simple I though I'd avoid having to spell all of that out in code, simply having a common struct 'Calculator' that has a lot of fields, each representing a "maybe finsihed" "maybe pending" future. In that way they can await each other and I can write "linear code" for the logic.
I have found futures::Shared that seems to support that particular usecase (though the types becomes very verbose) - but I'm struggling to get it to even compile.
Any pointers to help me understand the compiler error message for the following minified example (and what to do about it) would be apprechiated.
jh.boxed().shared() returns the Future with Send bound which derives from the async block and .boxed(). So the compile found it and reported that. But your return type didn't carry the bound, thus the error.
Also note that though dyn Trait + Send can coerce to dyn Trait, it doesn't happen in nested contexts: