4 ms·
What I think this comes down to, is that in Rust: It is easy but dangerous to call a non-async function from an async function (since the non-async function co
by lalaithion 2y ago
What I think this comes down to, is that in Rust:
It is easy but dangerous to call a non-async function from an async function (since the non-async function could block, forcing all your async code to block on this function).
It is hard but safe to call an async function from a non-async function.
Note that this is language specific; if Rust had “async”, “pure”, and “blocking” as three different function colors, then we would have a very different design. Or, for example, in JavaScript:
It is easy and safe to call a non-async function from an async function, since JavaScript exposes no blocking primitives.
It is impossible to call an async function from a non-async function, since there is no way to block on the result.