News for hackers. Stuff that matters.
Re:Rust without the async (hard) part by kirbyfan64sos on Thursday June 09, 2022 @11:45AM (#31682652)
If your program is mostly synchronous, you can manually create the async runtime and just use block_on to call async functions from a sync context: https://tokio.rs/tokio/topics/bridging#a-synchronous-interfa...
Re:Rust without the async (hard) part by abiro on Thursday June 09, 2022 @12:13PM (#31683053)
Even simpler to use `futures::executor::block_on`. No need to create a runtime, you can just call the function.

https://docs.rs/futures/latest/futures/executor/fn.block_on....

Re:Rust without the async (hard) part by Matthias247 on Thursday June 09, 2022 @01:10PM (#31683907)
That will only allow to run futures which have no IO dependency. Other typically expect a certain runtime to be running, because they eg use the epoll loop of that runtime to make progress.
Re:Rust without the async (hard) part by mamcx on Thursday June 09, 2022 @12:37PM (#31683389)
No, this not work well.

The highly infectious nature of async means you need to do that A LOT.

ie: reverse ALL things await.

That is too much. I refactor all my codebase (a huge refactor!) because this.

Re:Rust without the async (hard) part by jen20 on Thursday June 09, 2022 @02:06PM (#31684680)
What would you prefer the alternative to be? Library authors to do dual implementations of everything?
Re:Rust without the async (hard) part by slightknack on Thursday June 09, 2022 @02:15PM (#31684811)
A language with a function-color-agnostic effect system, generic over asynchronicity?
Re:Rust without the async (hard) part by Georgelemental on Thursday June 09, 2022 @04:43PM (#31686598)