Async vs. not-async function sub-typing

A function that takes a throwing closure as a parameter can use a non-throwing closure as an argument, since non-throwing functions are subtypes of throwing functions. Does the same apply for async vs. non-async? Can I stick a synchronous function as an argument for code expecting an async closure parameter?

Actually, in general, how can an async function call a regular one? And vice versa?

There's an implicit conversion from sync to async, like throws [SE-0296].

You can't call async function from sync caller. You'd need an API, like structured concurrency for that.

Terms of Service

Privacy Policy

Cookie Policy