logoalt Hacker News

tcfhgjyesterday at 5:39 PM2 repliesview on HN

yes, you can:

    runtime.block_on(async { })
https://play.rust-lang.org/?version=stable&mode=debug&editio...

Replies

messeyesterday at 6:37 PM

Let me rephrase, you can't call it like any other function.

In Zig, a function that does IO can be called the same way whether or not it performs async operations or not. And if those async operations don't need concurrency (which Zig expresses separately to asynchronicity), then they'll run equally well on a sync Io runtime.

show 1 reply
whytevuhuniyesterday at 6:34 PM

Here's a problem with that:

    Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
https://play.rust-lang.org/?version=stable&mode=debug&editio...
show 1 reply