Last active
July 26, 2019 16:10
-
-
Save benbrittain/22ce62dc823defac5fc54e2160f084f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(async_await)] | |
pub async fn bar() -> u32{ | |
5 | |
} | |
pub async fn foo() -> u32{ | |
let z = bar().await; | |
5 + z | |
} | |
// Sorta lowered code | |
pub async fn bar() -> ::std::future::from_generator(move || { 5 }) | |
pub async fn foo() -> ::std::future::from_generator(move |context| { | |
let z = { | |
let mut pinned = bar(); | |
let mut context = context; | |
loop { | |
match F::poll((unsafe { <::std::pin::Pin>::new_unchecked(&mut pinned) }), context)) { | |
::std::task::Poll::Ready(result) => break result , | |
::std::task::Poll::Pending => { } | |
} | |
context = yield (); | |
} | |
}; | |
5 + z | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment