async-await: add current_thread::Runtime::block_on_async (#1072)

This function is used by the Tokio macros introduced by #1058  but was
omitted from the PR.
This commit is contained in:
Carl Lerche
2019-04-30 19:55:22 -07:00
committed by GitHub
parent 219f24cbf1
commit 4ef736b9d5
8 changed files with 73 additions and 15 deletions
+22
View File
@@ -0,0 +1,22 @@
#![feature(await_macro, async_await)]
use tokio::await;
use tokio::timer::Delay;
use std::time::{Duration, Instant};
#[tokio::test]
async fn success_no_async() {
assert!(true);
}
#[tokio::test]
#[should_panic]
async fn fail_no_async() {
assert!(false);
}
#[tokio::test]
async fn use_timer() {
let when = Instant::now() + Duration::from_millis(10);
await!(Delay::new(when));
}