logo
  • Search
  • Reddit Posts 🔥
  • Archive
  • GitHub

TIL: one can return from an async block

122 points matklad 2022-09-05 14:05:08
View on Reddit ↗

Didn't realize before today that the following is possible:

#[tokio::main]
async fn main() {
    let f = async { return 92 };
    assert_eq!(f.await, 92);
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f14b1095e08fa7a0a9fb67f69063934e

© 2025 Query.rs, built by Folyd with ❤️❤️, see about page to learn more · meiguo.app · aiberm.com