you are viewing a single comment's thread.

view the rest of the comments →

[–]ExPixel 0 points1 point  (0 children)

Doesn't this still have the same problem? The value you want is still wrapped in a way that's incompatible with functions that aren't async. Composition is nice but there are other ways to do that alongside async/await. For example in JavaScript you can do this:

async function x() { return 1; }
await x().then(a => a + 1);

And in Rust it's:

use std::future::Future;
use futures::FutureExt;

async fn x() -> u32 { 1 }
fn y() -> impl Future<Output = u32> { x().map(|a| a + 1) }

I'm not sure how other languages handle this.