4 ms·
you can convert a float to a u32. you cannot convert an function that calls async code into a sync function.
by randyrand 3y ago
you can convert a float to a u32.
you cannot convert an function that calls async code into a sync function.
- kevingadd 3y agoYou can call .Wait on the Task it returns :)
- randyrand 3y agoRight, but now you are forced to convert the calling function to async. u32 / float does not have the problem. It does not "bubble up", unless you want it to.
- kprotty 3y agono, .Wait in C# or block_on in Rust keep the caller sync while evaluating the async callee, preventing the "bubble up".
- hgomersall 3y agoAn async function is some syntactic sugar around a sync function that returns a future. You can merrily call one from the other. You can only convert an int to a float with significant caveats. It's not a general trivial conversion. More complicated types may not be convertible at all or behave in all sorts of exciting ways (including having arbitrary side effects). The point is that none of that is different to async functions. Of course you have to know what to do with them for them to be useful, but there is no requirement for them to "infect" calling code.