Async Rust is amazing, but not flawless; async bloat is an issue. In this blog, @diondokter explains the causes of async bloat, and some workarounds: https://tweedegolf.nl/en/blog/235/debloat-your-async-rust

#rustlang #embedded #async

Debloat your async Rust - Blog - Tweede golf

Async Rust is amazing, but far from flawless. In this blog, I'll walk you through the current struggles and possible solutions.

@tweedegolf @diondokter As for returning ready(value), what's keeping the compiler from performing that optimization?
@tweedegolf @diondokter Ah, think twice, post once: It's the guarantee that async code only runs when polled, not when constructed. So, (how) can we waive that without too much fuss?
@chrysn You still create a future object with a poll function. And then in poll you return the value
@diondokter Now got the sad confirmation from trying on the playground: Indeed what I thought would be a half-way step towards a more idiomatic loading function looks no less complex than what the async fn does. (That'd be the load_semi function in <https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=f8c9a2dc1afaba72ea3d022de3655987>)
Rust Playground

A browser interface to the Rust compiler to experiment with the language

@chrysn Yep, an async block *always* generates a full statemachine