Created
July 30, 2019 18:12
-
-
Save benbrittain/47e45f8f23f19b38b89fb7ef7df40e66 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)] | |
#[prelude_import] | |
use ::std::prelude::v1::*; | |
#[macro_use] | |
extern crate std as std; | |
pub async fn bar() | |
-> | |
::std::future::from_generator(move | |
|mut async_ctx: | |
&mut core::task::Context| { 3 }) | |
pub async fn foo() | |
-> | |
::std::future::from_generator(move | |
|mut async_ctx: | |
&mut core::task::Context| | |
{ | |
let z = | |
{ | |
let mut pinned = bar(); | |
loop { | |
match ::std::future::poll_with_context(unsafe | |
{ | |
<::std::pin::Pin>::new_unchecked(&mut pinned) | |
}, | |
async_ctx) | |
{ | |
::std::task::Poll::Ready(result) | |
=> break result , | |
::std::task::Poll::Pending | |
=> { | |
} | |
} | |
async_ctx = | |
(yield ()); | |
} | |
}; | |
2 + z | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment