3 ms·
> How do you deal with a situations when you have non-async/await code, and then you need to call just one function, which happened to be "async" This depends
by Tuna-Fish 7y ago
> How do you deal with a situations when you have non-async/await code, and then you need to call just one function, which happened to be "async"
This depends on what do you want to happen. Do you want to block on the one async function, or do you want to turn your current function into async and propagate the asyncness to your caller?
Both options are available to you in Rust.
- ummonk 7y agoI think the people criticizing it are, like me, coming from other languages where blocking on async doesn't make your function sync. The asyncness still ends up propagating to the caller function in such languages.
- Tuna-Fish 7y agoThank you for putting it explicitly, everything here suddenly makes so much more sense. But yes, in Rust async is not a plague that irredeemably taints everything. You can choose to use anything that is async synchronously if you choose to, just by calling .poll() on the future at the callsite.