Post

Async in Rust doesn't even meet the critical criteria for the coloring problem in Bob Nystrom's original post: 🧵

david barsky@davidbarsky.com

i want people who get riled up about "function colors" to tell me whether they view the difference between `fn foo() -> String` and `fn foo() -> Result<String, Error>` to also be an example of problematic function coloring

2 reposts13 likes

2. "The way you call a function depends on its color": you can call an async function in Rust normally and just get the future if you want. You can give that to an executor or combine it with other futures. If you're in an `async` function yourself you can `.await` it.

3. "You can only call a red function from within another read function": See #2, you can call async functions from sync functions. You can even write your own executor if you want. @mgattozzi.dev made a nice example one to teach people how to do this: github.com/mgattozzi/wh...

github.comGitHub - mgattozzi/whorl: single file, std only, async Rust executorsingle file, std only, async Rust executor. Contribute to mgattozzi/whorl development by creating an account on GitHub.